2016-04-03 40 views
0

如何在Java脚本只得到图像的SRC值

我使用的jqGrid图像标签此值,当我打电话

$('#testGridList').jqGrid ('getCell', id, 'pic'); 

这回

<img src="http://localhost:8080/myApp/DownloadFile?type=THU_IMG&amp;id=409" height="70" width="90" class="example1tooltip" style="cursor:pointer" alt="photo" title="View Org photo" onclick="getUxx()"> 

怎么办我只得到src的价值?

回答

0

attr()使用尝试,如下所示: -

var gridcell = $('#testGridList').jqGrid ('getCell', id, 'pic'); 
var imgsrc = $(gridcell).attr("src"); 

DEMO

+0

.getAttribute( “SRC”)不工作。 “Uncaught TypeError:$(...)。jqGrid(...)。getAttribute不是函数” – iTech

+0

@ iTech ..查看更新ans。 –

+0

谢谢..更新后的代码正在工作:) – iTech

0

你可以得到如下的src值。

var src = $('#testGridList').jqGrid ('getCell', id, 'pic').src; 
相关问题