一旦发生onclick事件,如何禁用它?
问题描述:
当 onclick()
<img src="images/add.png" onclick="add_cart()">
我想让用户点击图片一次。当用户第一次点击它时,应该调用 add_cart
函数。
I want the user to click the image only one time. When the user clicks it first time, add_cart
function should be called. If he clicks second time no event should happen.
答
如果你在jquery方面处理这个问题,你可以使用jquery one
方法
If you are dealing this on jquery side,you can use jquery one
method
$(".myDiv").one("click", function(){
alert("this will happen only once");
});
干杯