Reputation: 32331
I have the div structure as shown below
<div data-role="collapsible">
<div class="prd-items-detials">
<ul>
<li class="head">
<form><input type="checkbox" class="checkboxclas" name="checkbox-mini-0" id="' + random_number + '" data-mini="true">
<label class="testtt" for="checkbox-mini-0">Somelabel</label>
</form>
</li>
<li class="prd-items-qt">
<div class="col">
<span class="prd-sm-img">
<img id="imagesd" type="img" height="40" width="40" src="myimage.jpg"/>
<span>
</div>
<div class="col">
<i class="minus">
</i>
<i class="qt">1</i>
<i class="plus"></i>
</div>
<div class="col">
</div>
<div style="display: none;" class="price">120</div>
<div class="total">150</div>
</li>
</ul>
</div>
</div>
On click of the checkbox , i am unable to access the image src
I tried this way , but its not coming . could anybody please help ??
$(document).on("click", ".checkboxclas", function (e)
{
if ($(this).is(':checked'))
{
var price = $(this).closest("ul").find("div.price").text();
var image = $(this).closest('div[data-role="collapsible"]').find("imagesd").src.text();
}
});
Upvotes: 0
Views: 46
Reputation: 62498
you have to use prop() or attr() to get the src of img like this:
var image = $(this).closest('div[data-role="collapsible"]').find("#imagesd").attr("src");
Upvotes: 0
Reputation: 82251
You can use:
$(this).closest('li').next().find('img').attr('src');
or
$(this).closest('ul').find('img').attr('src');
If you have only one image in each ul
element markup above.
Upvotes: 1