Jessie Campbell Jessie Campbell -5 years ago 98
jQuery Question

css method doesn't work with variable

var slidemenu_width = $('.inverse').css('width');
$('#slide-nav .navbar-toggle').css({'left':slidemenu_width + 'px'});

what's wrong with this code? I don't see the css been applied to my selector.

Answer Source

Try this example:

<div class="inverse" style="width:25px;"></div>
<div class="navbar-toggle"></div>

var slidemenu_width = $('.inverse').css('width');
$('.navbar-toggle').css('left',slidemenu_width); // add css like this
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download