2

I know that with the jQuery expression $(element).on("mousedown", function(evt) { ... }); you can handle mousedown events on an element.

Though I need to detect the mousedown or click event on the browser's scroll bar and need to run some function.

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
Javed Saifi
  • 192
  • 1
  • 11
  • 2
    Here there are multiple answers: http://stackoverflow.com/questions/4326845/how-can-i-determine-the-direction-of-a-jquery-scroll-event – sxanus Jan 15 '16 at 05:10
  • this is related to scroll count but i am looking for click or mousedwon – Javed Saifi Jan 15 '16 at 05:16
  • http://stackoverflow.com/questions/10045423/determine-whether-user-clicking-scrollbar-or-content-onclick-for-native-scroll – Mario Tacke Jan 15 '16 at 05:43

1 Answers1

11

I suggest capturing the mousedown event and testing for the coordinates. If the coordinates are greater than or equal to the visible document body width, they clicked in the scrollbar area!

$(document).ready(function() {
  $(document).mousedown(function(event) {
    if(event.target === $('html')[0] && event.clientX >= document.documentElement.offsetWidth)
      alert('vertical scrollbar clicked');
  })
})
Nate
  • 1,268
  • 13
  • 20