kitty sarvaj
kitty sarvaj

Reputation: 527

Changing the image src Nested Inside Div

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

Answers (2)

prog1011
prog1011

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

Shalinee SIngh
Shalinee SIngh

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

Related Questions