Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we prevent default actions in JavaScript?

Tags:

javascript

What is the cross-browser method? I need to prevent any default action on an image, so that neither dragging nor anything else will fire on a default bases.

like image 617
Ale Anderson Avatar asked Mar 13 '26 03:03

Ale Anderson


1 Answers

You can register the events you want to cancel, and then either return false from them or use Event.preventDefault(), depending on the browser and event.

like image 123
jonchang Avatar answered Mar 14 '26 15:03

jonchang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!