javascript - issue updating variable on window resize -
javascript - issue updating variable on window resize -
i have status size of browser window variable "windowsize" doesnt updated , value on document load 1 considered. doing wrong, need global variable?
here have:
jquery(function(){ jcf.customforms.replaceall(); initcarousel(); initcyclecarousel(); initslideshow(); initopenclose(); initaccordion(); jquery('input, textarea').placeholder(); ..... ... }); ..... ... // open-close init function initopenclose() { var $window = $(window); var windowsize = $window.width(); $(window).resize(function() { windowsize = $window.width(); }); if (windowsize > 1200) { //if window greater 1200px wide then.. jquery('#nav > ul > li').openclose({ activeclass: 'active', opener: '> a', slider: '.drop-container', animspeed: 200, event: 'over', effect: 'slidealt' }); } if (windowsize < 1200) { //if window greater 1200px wide then.. jquery('#nav > ul > li').openclose({ activeclass: 'active', opener: '> a', slider: '.drop-container', animspeed: 400, event: 'click', effect: 'slidealt' }); } });
}
try with
jquery(function(){ updatecontainer(); // initial load phone call check did not require resize }); $(window).resize(function () { updatecontainer(); // if resize happens phone call check }); function updatecontainer() { var windowsize = $(window).width(); if (windowsize > 1200) { //if window greater 1200px wide then.. jquery('#nav > ul > li').openclose({ activeclass: 'active', opener: '> a', slider: '.drop-container', animspeed: 200, event: 'over', effect: 'slidealt' }); } else { jquery('#nav > ul > li').openclose({ activeclass: 'active', opener: '> a', slider: '.drop-container', animspeed: 400, event: 'click', effect: 'slidealt' }); } }
javascript jquery css
Comments
Post a Comment