javascript - jQuery do code if class is changed -


i'm trying check li inside other li having class is-visible, , in case nothing, if doesn't add style width: 0px.

if (jquery("li:has(li.is-visible)")){     //nothing @ moment } else {     jquery('ul.cd-gallery li').css({'width' : '0px'}); } 

html part of code

<ul class="cd-item-wrapper">         <li data-type="sve" class="is-visible">         <img class="img-reponsive" src="someimg.jpg" alt="jabuka" height="150" />         </li>         <li data-type="proizvodi" class="is-hidden">             <img class="img-reponsive" src="someimg.jpg" alt="jabuka" height="150" />         </li>         <li data-type="vocnaci" class="is-hidden">             <img class="img-reponsive" src="someimg.jpg" alt="jabuka" height="150" />         </li>                            </ul> </li> 

but i'm using jquery change class is-hidden is-visible , vice versa. code not see changes, , have group display images. if helps here link page my site

mine jquery code good, @ least think, issue (if u inspect element on site) u see bunch of

  • , wehn u change category need hide elements (width:0) dont't have li > ul > li class="is-visible"

  • you can detect if element has class either using hasclass() (which recommended it's fastest):

    if ( $("li > ul > li").hasclass('is-visible')) {     //nothing @ moment } else {     $('ul.cd-gallery li').css({         'width', '0px'     }); } 

    or is():

    if ( $("li > ul > li").is('.is-visible')) {     //nothing @ moment } else {     $('ul.cd-gallery li').css({         'width', '0px'     }); } 

    Comments

    Popular posts from this blog

    Payment information shows nothing in one page checkout page magento -

    tcpdump - How to check if server received packet (acknowledged) -