Kumar Ravishankar

Kumar Ravishankar

  • NA
  • 437
  • 7.9k

Issue in image clone using jquery

Jul 26 2022 5:13 AM

<div class="left">

<div class="row">

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image1.png:>

</div>

</div>

 

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image2.png:>

</div>

</div>

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image3.png:>

</div>

</div>

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image4.png:>

</div>

</div>

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image5.png:>

</div>

</div>

<div class="column">

<div class="group1">

<img class="myImage" src="images/Image6.png:>

</div>

</div>

</div>

</div>

//

<div class="ceneter">

<div class="divImage">

<img class="defaultimg" src=""src="images/defailt.png>

 

</div>

</div>

 

I am trying to clone the images to  <img class="defaultimg" src=""src="images/defailt.png>

when click on <img class="myImage" src="images/Image3.png:>  (this is the repetative images like 6-8 images there)

Issue : its replacing only one image which is in very first.


 

$( document ).ready(function() {

$(".myImage").on("click",function()){

var sourceimg=$('img[class="myImage"]').attr('src')

$('img[class="defaultimg"]').attr('src',sourceimg);

});

});

 


Answers (1)