我有一個觀點有很多圖片jQuery的數據屬性得到這個元素
<img src="@Path" data-img-prev="@UrlPreview" data-full-path="@UrlImage" onclick=Get() />
,並在HTML中呈現這樣
<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">
我想函數從每個元素中獲取數據
function Get() {
this.getAttribute('img-path');
this.data('img-path');
}
它不能正常工作,請幫助:
錯誤this.getAttribute不是一個函數
你怎麼稱呼TTT()函數? ??它是Get()函數嗎? –
你必須改善你的問題。什麼是呈現的HTML?很明顯,這不是你所發佈的... –
給我一瞬間它如此之快 – user246340