I am trying to retrieve data from an img element inside a html web page using jQuery.
I know from the start that there is only 1 image but when I run the following code, I get 2 alert boxes. They contain the same information..
Does anyone know what i am 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>
srcone img per tdthere must be two tds...