javascript - Getting the src attribute of an image within a parent tag -
i have list of images, 1 of gets class="selected" after change occurs on page:
<div id="selectable"> <li> <img src="\images\1.jpg" /> </li> <li class="selected"> <img src="\images\2.jpg" /> </li> <li> <img src="\images\3.jpg" /> </li> </div>
i want able capture value of image's src attribute, can use later... i'm thinking this:
$("#selectable").change(function() { var src = $('li[class="selected"]').attr('src'); alert("source of image alternate text = example - " + src); }
but need value of src attribute of child element (img).
$("li.selected").find("img").attr("src");
Comments
Post a Comment