jquery - Adding class and dropdown on resize window? -


i have jquery on screen size. problem want on event resize window. here have now:

if ($(window).width() >= 1000) {     jquery('ul.nav li.dropdown').hover(function () {         jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadein();     }, function () {         jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeout();     });     jquery(".menu-heading").addclass("disabled");     jquery(".menu-submenu").addclass("text-right"); } else {     jquery(".menu-heading").removeclass("disabled");     jquery(".menu-submenu").addclass("text-center"); } 

i work on load, want on resize if screen smaller remove , add

jquery(".menu-heading").removeclass("disabled"); jquery(".menu-submenu").removeclass("text-right"); jquery(".menu-submenu").addclass("text-center"); 

this has happen on window load , on window resize, help?

use window resize() , , call same function in using on window onload.

$( window ).resize(function() {      //your function  }); 

this won't work.

jquery('ul.nav li.dropdown').hover(function () {     jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadein(); }, function () {     jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeout(); }); 

use mouseover() instead,

jquery('ul.nav li.dropdown').mouseover(function () {     jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadein(); }, function () {     jquery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeout(); }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -