var imgs = $("#pictureQueryTable img").prevObject[0].images;下圖是上面這句打印出來的結(jié)果:console.log可以打印出來該集合的數(shù)據(jù),但是無法獲取該集合中的每一個值,打印該集合的length為0,所以也無法遍歷該集合進(jìn)行操作。查資料看有人說要在dom結(jié)構(gòu)完全加載完成之后才能操作,但是試了之后發(fā)現(xiàn)還是不行。下面這個圖是console.log($("#pictureQueryTable img"))打印出來的數(shù)據(jù)代碼結(jié)構(gòu)是這樣的:圖片生成代碼是這樣的:{ title : "", name : "PICTURE_NAME1", width : 320, lockWidth : false, align : "center", renderer : function(val, item, rowIndex) { if (item.COLLECTION_NAME1 != undefined) { picture_path = "image/no_picture.png"; var picture_name = item.COLLECTION_NAME1 + "(" + item.COLLECTION_CODE1 + ")"; if (item.PICTURE_PATH1) { picture_path = getLocaleHostPath() + item.PICTURE_PATH1; } val = val != null ? val : ""; return "<div style='width:310px;height:100%;text-align:center;background-color:white;padding-top:5px;'><div>" + "<a href='javascript:void(0)' onclick='openPage(\"html/showcenter/collection/collectionstatistical/picturequery/PictureDetailInfo.html?id=" + item.COLLECTION_ID1 + "&collection_code=" + item.COLLECTION_CODE1 + "\",\"1300,600\")'>" + "<img alt='圖片' style='width:200px;height:200px;' title='"+val+"' src='"+picture_path +"'/></a></div><span style='margin-top:5px;'>" + picture_name + "</span></div>"; } else { return ""; } } }
HTMLCollection集合能打印出來值,但是無法獲取每一個值。
尚方寶劍之說
2019-03-20 18:19:42