0
我想添加一個點擊事件到這個img標籤。它在桌面上運行良好,有時在ipad上運行。但它從來不適用於移動設備。 我已經試過`onclick和ontouchstart不能在移動工作
<img src="http://placehold.it/200x200" class="img-center" ontouchstart="addImagesToArray()"/>
和
<img src="http://placehold.it/200x200" class="img-center" onclick="addImagesToArray()"/>
只是爲了測試移動。但似乎沒有人工作。 這是我的js的樣子
function addImagesToArray(){
alert("clicked!");
}
我不知道爲什麼這是行不通的,因爲我甚至都不在控制檯中看到一個錯誤。我真的迷失在這裏。任何人都可以幫助我嗎?
對我來說工作很好... – Rayon
它的工作..只有簡單的代碼才能運行。或包含您的完整的JavaScript? – prasanth