Reputation: 527
I have image tag which is generated dynamically inside the nested div.I want to change the image src of image tag to null or empty src,Need help below is the my div which is getting generated like
<div class="imageone">
<div class="rad imguser">
<image class="imgpic" src="xxxx.jpeg" />
</div>
</div>
Upvotes: 0
Views: 1135
Reputation: 3495
Try This
You can use .find() and .attr()
.find() Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
.attr() Get the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
$(document).ready(function(){
$(".imageone").find('image').attr('src','');
// OR if you know the class name or id of the image tag than you can use as below.
$(".imgpic").attr('src','');
});
Upvotes: 1
Reputation: 209
You can jQuery selectors and change the src of image tags.
$(".imgpic").attr('src', '');
console.log($(".imageone").html());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="imageone">
<div class="rad imguser">
<image class="imgpic" src="xxxx.jpeg" />
</div>
</div>
Upvotes: 1