Need to append image to to div.

Need to append image to to div.


Okay so on click function I do this: 
var item_img = $( ' #itemImg ') . attr( " src ");

I get the src of the image. 

And then the problem is that I have more than one item but each item have the same class. So whether I click on second image or on third I still append first item image. I need to get somehow unique image when I click button. This is the code:

  1. <ul style="list-style: none;"> 
  2. <li class="text-center"> 
  3. <div class="popup"> 
  4. <img class="item" id="itemImg" src="{{this.img}}"><br> 
  5. <span class="popuptext" id="myPopup"> 
  6.  Power: <p id="power">{{this.power}}</p> 
  7. </span> 
  8. </div> 
  9. <br> 
  10. <p><span id="title">{{this.title}}</span> 
  11. <button class="btn btn-danger buyItem" style="font-size: 12px" id="{{this._id}}">Buy | <span id="price">{{this.price}}</span> <img src="/img/gold.png"></button> 
  12. </p> 
  13. </li> 
  14. </ul>