2016-04-03 39 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; 
相關問題