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:
- <ul style="list-style: none;">
- <li class="text-center">
- <div class="popup">
- <img class="item" id="itemImg" src="{{this.img}}"><br>
- <span class="popuptext" id="myPopup">
- Power: <p id="power">{{this.power}}</p>
- </span>
- </div>
- <br>
- <p><span id="title">{{this.title}}</span>
- <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>
- </p>
- </li>
- </ul>