javascript - Prevent default only on parent or change the target of the prevent default -


i listening on scroll event on div (let's name scroll_div) contains textarea.

in given scenario (the scenario not important) "e.preventdefault()" when scrolling.

when e.target textarea, don't want prevent scroll inside textarea... preven default on scroll_div.

i tried:

 if(e.target.type !== "textarea") {             this.preventdefault(e);//don't scroll         } else {             this.stoppropagation(e);         } 

but when - body scrolling (and don't want happened)

suggestions?

you might looking for:

event.stoppropagation();         

prevents further propagation of current event.

this should stop events bubbling dom. more details can found here - https://developer.mozilla.org/en-us/docs/web/api/event/stoppropagation

okay doesnt work -

$('#foo').scroll(function(ev) {     ev.preventdefault(); }); 

because scroll event happens on scroll, not actual scroll event itself.
called either mousewheel or dommousescroll, depending on browser. doing:

$('#foo').on('mousewheel dommousescroll', function(ev) {     ev.preventdefault(); }); 

should trick.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -