!onclick atribute | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

!onclick atribute

Is there a noclick atribute or any thing like that?

4th May 2017, 6:26 AM
jason
jason - avatar
3 Answers
+ 10
A 'notclick' event isn't technically possible, as it will suppose that it's continously fired :P But with 'onclick' event, you can handle a variable to store the state of the 'click' thanks to others 'click' events: 'onmousedown' is fired when the mouse button is pushed, while 'onmouseup' when the mouse button is released... So: <script> var clickState = false; </script> <div id="myDiv" onmousedown="clickState=true;" onmouseup="clickState=false;"> ... obviously, you have to read the value of the global variable storing the state. You need to improve it for handle different element context, and/or set this handler to the <body> tag for having a kind of global mouse 'not' click listener ^^
4th May 2017, 3:29 PM
visph
visph - avatar
+ 5
thnx :)
5th May 2017, 5:56 PM
jason
jason - avatar
+ 4
noclick attribute don't exsist :) But good question, this interest me also :)
4th May 2017, 6:49 AM
Nikola Stojiljkovic
Nikola Stojiljkovic - avatar