File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes how to disable onclick event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to disable onclick event" Watch "how to disable onclick event" New topic

how to disable onclick event

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I have an input tag with type=button, and an onclick event being set on it. When I disable this button by adding disabled=disabled to it, I still can click and trigger the onclick JS function of this button.

Why is the onclick still working when the button is disabled? How could I also disabled the onclick event? Thanks

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Which browser are you using? Show a working code snippet. I cannot reproduce this in FF and IE.

The disabled one doesn't show up the alert when clicked. Neither IE nor FF.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

[My Blog]
All roads lead to JavaRanch
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
thanks guys, yeh, it's actually my fault. when I look closer in the code, I saw that button is inside a td tag, I disabled the td, the button looks like disabled, as greyed out, but onclick is still working. when I disabled with the button id, it worked.
I agree. Here's the link:
subject: how to disable onclick event
It's not a secret anymore!