admin管理员组文章数量:1410682
I am using onClick event for the image.
When I am disable for the particular case, I didn't know exactly how can disable the onClick
functionality using JavaScript.
Sample code:
<td>
<a onClick="fun()">
<html:img src="/caleder.jpg ... />
</a>
</td>
calling fun:
function fun() {
// in fun I want to disable the img and onClick functionality
// i.e when I click that img, then it can't perform the onClick event.
}
I am using onClick event for the image.
When I am disable for the particular case, I didn't know exactly how can disable the onClick
functionality using JavaScript.
Sample code:
<td>
<a onClick="fun()">
<html:img src="/caleder.jpg ... />
</a>
</td>
calling fun:
function fun() {
// in fun I want to disable the img and onClick functionality
// i.e when I click that img, then it can't perform the onClick event.
}
Share
Improve this question
edited Oct 23, 2010 at 13:10
Arseni Mourzenko
52.5k35 gold badges118 silver badges210 bronze badges
asked Oct 23, 2010 at 13:01
CHANTICHANTI
1,4753 gold badges13 silver badges10 bronze badges
4 Answers
Reset to default 3The probably most efficient way since it removes the event listener:
<script>
function fun(node) {
document.getElementById(node).removeAttribute("onClick");
}
</script>
Inside of the onClick()
you need to place a this
so it would be onClick(this)
I usually just set a variable and put the events in the onClick handler inside a conditional statement. Set the variable on the first click, and next time it won't fire.
<script>
var i = 0;
function clickHandle(){
if(i==0){
//do stuff
i=1;
}
<script>
you can easy handle this issue with this code after you function see this codes
function disableClick() {
document.getElementById('yourId you want disable on click').onclick = "";
}
and enable same this code
The best way IMO.
function fun()
{
if (this.clicked == undefined)
{
this.clicked = true;
// have fun
}
return false;
}
本文标签: Disable onClick functionality using JavaScriptStack Overflow
版权声明:本文标题:Disable onClick functionality using JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744792630a2625384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论