I have a view with a lot of images
<img src="@Path" data-img-prev="@UrlPreview" data-full-path="@UrlImage" onclick=Get() />
and it render in html like this
<img img-prev="1.jpg" data-full-path="https://...1.jpg" src="https://...1.jpg">
<img img-prev="2.jpg" data-full-path="https://...2.jpg" src="https://...1.jpg">
<img img-prev="3.jpg" data-full-path="https://...3.jpg" src="https://...1.jpg">
I want function to get data from each element
function Get() {
this.getAttribute('img-path');
this.data('img-path');
}
It is not working please help:
error this.getAttribute is not a function
The data attribute is called
data-full-path
, notimg-path
.or since you tagged it with jQuery (assumings you're in a click handler context):