Sunday, 29 September 2013

Toggle and change class using jQuery

Toggle and change class using jQuery

I'm trying to change $mobile-nav-button's class to .navon and make effect
to slide it from left and add another class to another div. The part where
$mobile-nav-button's class changes works, and my animation works first
time, but then it doesn't hide, why? And the part where I try to change
another div's class doesn't work neither. And the # symbol appears in URL
bar from link which shouldnt..
I aprriciate any help!
$(document).ready(function() {
$("#mobile-nav-button").click(function() {
$("#mobile-nav-button").toggleClass("navon");
if($("#mobile-nav-button").hasClass("navon")) {
$("#mobile-nav").toggle('slide', {
direction: "left"
}, 1000);
$("mobile-content-panel").toggleClass("show-nav");
} else {
$("#mobile-nav").toggle('slide', {
direction: "left"
}, 1000);
$("mobile-content-panel").toggleClass("hide-nav");
}
});
});

No comments:

Post a Comment