Reputation: 303
Pretty much title, I would like to allow scrolling in a DIV, but disable click events. Does anyone know any way this could be accomplished?
Thank you!
Upvotes: 3
Views: 4628
Reputation: 1
var myDiv = document.querySelector('#myDiv');
myDiv.addEventListener('click', function(){
return false
});
Upvotes: 0
Reputation: 2290
For me create a special class that prevents click events then wrap these element(s) with a scrollable container.
<div class="scrollable-div">
<div class="child-div noclick">
//anything else
</div>
</div>
and your js would look like
$('.noclick').click(function(event){
// prevent default behavior of click
event.preventDefault();
return false;
});
Hope that helps
Upvotes: 1