I'm having a strange issue checking whether a div I just created with .wrap()
is visible or not. I'm wrapping some divs and using the ID's on them as targets. I've tested to make sure the click is actually registering with an alert()
, and it is.
Here is the code.
//Leftbar jQuery
$('ul.leftnav').wrap('<div id="leftnav-wrap" class="five columns alpha" />');
$('#leftnav-wrap').prepend('<div class="arrow" />');
$('#content').has('#leftnav-wrap').find('#page').wrap('<div class="eleven columns omega" />');
//Mobile Leftbar
$('h4.mobile.toggle').click(function(){
if ($('#leftnav-wrap').is(':hidden')){
$(this).addClass('active');
$('#leftnav-wrap').addClass('active');
}
else{
$(this).removeClass('active');
$('#leftnav-wrap').removeClass('active');
}
});
Is there something inherently wrong with what I've coded? It doesn't toggle any of the active classes it is suppose to, and I have another site that is working fine, only it's not targeting an ID just created by .wrap()
.
JSfiddle here: jsfiddle.net/ZD7hz. Not toggling any classes