Ho una tela HTML5 e ho aggiunto un'immagine al suo interno e voglio chiamare click evento di immagine ma l'evento non si attiva. Sto scrivendo un codice html e un codice di jqmobileImmagine Fare clic su evento in HTML5 Canvas
<html>
<head>
<script src="jquery-1.10.2.min.js"></script>
<script src="jquery.mobile-1.2.1.js"></script>
<script src="jquery.mobile-1.2.1.min.js"></script>
</head>
<body>
<canvas id="canvas1" style="position: absolute; left: 0px; top: 0px;" width="1280" height="960">This text is displayed if your browser does not shown.
</canvas>
<script>
$(function() {
var ctx = document.getElementById("canvas1").getContext("2d");
var imgBasket = new Image();
imgBasket.id = "imgBasket";
imgBasket.src = "Basket.png";
ctx.drawImage(imgBasket, 580, 260, 200, 200);
//this jquery mobile event not working in canvas
$("document").on("vclick", "#imgBasket", function() {
alert("Hello");
});
});
</script>
</body>
</html>
che cosa è un VCLIC? è qualcosa che usa jquery mobile? O è solo che hai un errore di battitura in "click"? Ciò potrebbe causare il problema –
Inoltre, puoi creare un'immagine, dargli un ID e poi posizionarlo nella tela, ma le immagini nella tela non hanno ID, penso che –