.addClass from JQuery not working -


i got piece of code working fine:

$(window).resize(function() {     if ($(window).width() >= 1024) {         $("tbody button").addclass( "btn-lg" );         $("tbody button").removeclass( "btn-sm" );     } else if ($(window).width() <= 768) {         $("tbody button").removeclass( "btn-lg" );         $("tbody button").addclass( "btn-sm" );     } else {         $("tbody button").removeclass( "btn-lg" );         $("tbody button").removeclass( "btn-sm" );     } }); 

but doesn't work when open document since i'm not doing resize, added this:

$(document).ready(function() {     if ($(window).width() >= 1024)          $("tbody button").addclass( "btn-lg" );     else if ($(window).width() <= 768)         $("tbody button").addclass( "btn-sm" ); }); 

but somehow it's not working, inserted console.log see if code reaching inside if , indeed was, somehow it's not adding class.

any suggestions?

one possible alternative wrap buttons in visible-lg divs instead of using javascript. example:

<div class="visible-lg">     <button class="btn btn-lg"></button> </div> <div class="visible-md">     <button class="btn"></button> </div> <div class="visible-sm">     <button class="btn btn-sm"></button> </div> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -