My left sidebar is causing me some trouble. I want it to populate when clicked, but in my code, I have to double click on the "show menu" button to display the menu. What am I doing wrong?
$(document).ready(function () {
var slider_width = $('.menucont').width(); //automatically get width
$('#pollSlider-button').click(function () {
if ($(this).css("margin-right") == slider_width + "px" && !$(this).is(':animated')) {
$('.menucont,#pollSlider-button').animate({
"margin-right": '-=' + slider_width
});
$(".menucont").show();
$(".showmenu").css("display", "none");
$(".hidemenu").show();
} else {
if (!$(this).is(':animated')) //prevent double click from doubling margin
{
$('.menucont,#pollSlider-button').animate({
"margin-right": '+=' + slider_width
});
$(".showmenu").show();
$(".menucont").hide();
$(".hidemenu").css("display", "none");
}
}
});
});
I also have a fiddle URL: http://jsfiddle.net/6834Y/
Any help would be greatly appreciated.