0

Is there a jQuery event that fires only while holding down left mouse botton ?

I have tried the .mousedown() event but it doesn't seems to work for me.

  • 1
    I think that this answer your question [https://stackoverflow.com/questions/3977091/jquery-mousedown-effect-while-left-click-is-held-down](https://stackoverflow.com/questions/3977091/jquery-mousedown-effect-while-left-click-is-held-down) – Milan Mijatovic Jan 20 '22 at 11:45
  • 1
    As per [mre] please show what you have tried and provide a more detailed explanation of what you are trying to accomplish and what the code does differently from expectations. See also [ask] – charlietfl Jan 20 '22 at 12:21

1 Answers1

1

The button value in available in the mouse event. The buttons are numbered from the primary button at value 0 and upward. Look at this example.

const div = document.getElementById('log');
document.addEventListener('mousedown', function(e) {
    div.innerHTML+= ' '+e.button;
});
div {
  border: 1px solid #000;
  padding: 3px 5px;
  min-height: 1.5em;
}
<div id="log"></div>
Gil
  • 1,794
  • 1
  • 12
  • 18