I have a div inside a foreach loop I'm using to display content in view
<div class="someclass" data-id="[email protected]">
<p> text1 </p>
<p> text2 </p>
<span class="otherClass embedIcon"></span>
</div>
I'm trying to target the id attribute using the
$(".embedIcon")
.click(function () {
html2canvas($(this).data('data-id'),{
onrendered: function (canvas) {
var myImage = canvas.toDataURL("image/png", 1);
window.open(myImage);
}
});
});
When I click the icon on which embedIcon class is applied to generates an image, I get an image of all divs in the iteration.
How can I get the image of a specific div when I click the icon within the div?
html2canvas($(this).data('id')