javascript - jQuery iterate over table elements -



javascript - jQuery iterate over table elements -

i trying retrieve info img element within html web page using jquery.

i know start there 1 image when run next code, 2 alert boxes. contain same information..

does know doing wrong?

$("#tablex td").find("img").each(function() { if ($(this).data("apple") == "orange") { alert($(this).attr("src")); } });

thanks.

update:

dom output..

<td id="tdp4" align="center" style="border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(201, 201, 201); border-right-color: rgb(201, 201, 201); border-bottom-color: rgb(201, 201, 201); border-left-color: rgb(201, 201, 201); "><img id="imgp4" src="/images/t/00.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; width: 63px; height: 103px; display: block; background-color: rgb(71, 7, 79); " alt="00"></td>

there 2 possible reasons:

either have several rows containing image (the selector selects all images in whole table) or code run twice.

javascript jquery html iteration

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -