javascript - if div does not contain this class then execute following -


at moment have few div resize functions work on different page width queries. these working fine, want wrap of these functions different window widths in conditional statement.basically want functions resize div "portfoliopod" if div not contain class pod expanded. please see code below , live example at

http://mrliger.com/index2.php

you can see on live example image being clipped due having height of how portfoliopod before expanding it

 if ($( '.portfoliopod' ).not( ".podexpanded" )) {      $(window).resize(function() {         if ($(window).width() >= 1025) {  var cw = $(".portfoliocontainer").width()/4; $('.portfoliopod').height(cw);          }      });  $(window).resize(function() {         if ($(window).width() <= 1024) {  var cw = $(".portfoliocontainer").width()/3; $('.portfoliopod').height(cw);          }      });  $(window).resize(function() {         if ($(window).width() <= 767) {  var cw = $(".portfoliocontainer").width()/2; $('.portfoliopod').height(cw);          }      });  $(window).resize(function() {         if ($(window).width() <= 400) {  var cw = $(".portfoliocontainer").width(); $('.portfoliopod').height(cw);          }      });  }  

first, not need multiple resize handlers. include them in same one.

second, use :not() selector

  $(window).resize(function() {          if ($(window).width() >= 1025) {              var cw = $(".portfoliocontainer").width() / 4;              $('.portfoliopod:not(.podexpanded)').height(cw);          }          if ($(window).width() <= 1024) {              var cw = $(".portfoliocontainer").width() / 3;              $('.portfoliopod:not(.podexpanded)').height(cw);          }          if ($(window).width() <= 767) {              var cw = $(".portfoliocontainer").width() / 2;              $('.portfoliopod:not(.podexpanded)').height(cw);          }          if ($(window).width() <= 400) {              var cw = $(".portfoliocontainer").width();              $('.portfoliopod:not(.podexpanded)').height(cw);          }      }); 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -