• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to disable onclick event

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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é
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic