How to disable a button or div | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to disable a button or div

21st Aug 2017, 11:31 AM
Milind Pathak
Milind Pathak - avatar
6 Answers
+ 5
<button disabled>Disable button</button>
21st Aug 2017, 12:47 PM
Calviղ
Calviղ - avatar
+ 3
display: hidden
21st Aug 2017, 11:51 AM
Iwan
Iwan - avatar
+ 3
You can do something like: if(activated){ //do your stuff } The activated variable can be used to control if the button / div should do an action or not. You can make another function like "deActivate" to make the activated variable false, and in the same function you can do your CSS skills to make it look like it's inactive
21st Aug 2017, 12:31 PM
Limitless
Limitless - avatar
+ 2
That also works
21st Aug 2017, 12:47 PM
Limitless
Limitless - avatar
+ 1
I don't want to hide it , I just want that they should be visible but not clicked
21st Aug 2017, 12:07 PM
Milind Pathak
Milind Pathak - avatar
+ 1
delete event from js by default div and button have no click events
21st Aug 2017, 12:24 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar