javascript - Check height, then add or remove class -


i'm making navigation responsive. when width above number should class, when it's below, class should removed:

var width = $("#primary-header-nav").width(); if ( width < 770) {   $('#primary-header-nav li a').addclass('box-1-9');     } else {   $('#primary-header-nav li a').removeclass('box-1-9');  } 

however, in reality, class never assigned. regardless of width.

this site if of help: http://darylkeep.com/aanbod/

try this.

$(document).ready(function(){   $(function(){     $(window).on("resize", function(){        var width = $(this).width();       var links = $('#primary-header-nav li a');        if(width < 770){         links.addclass('box-1-9');       }else{         links.removeclass('box-1-9');       }     });   }); }); 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -