Reputation: 159
I am new to JQuery and I am having some trouble getting my code to work just right. For some reason my JQuery is hiding the link (a) element. I need the link to toggle the 'wrap' div. What could I be doing wrong?
JQuery:
$(document).ready(function() {
$('.wrap').hide();
$('.open').toggle(
function() {
('.wrap').show();
},
function() {
('.wrap').hide();
}
); // end toggle
}); // end ready
Upvotes: 2
Views: 309
Reputation: 255085
$('.wrap').hide();
$('.open').click(function() {
$('.wrap').toggle();
return false;
});
So on every "Notifications" link click you're toggling the .wrap
The real roots of the issue with your code: The .toggle()
event handler was REMOVED in jquery 1.9 -- http://api.jquery.com/toggle-event/, so what you're using in your code sample is animation method http://api.jquery.com/toggle/
Upvotes: 8
Reputation: 315
Just replace your jquery with
$(document).ready(function() {
$('.wrap').hide();
$('.open').click(function(e){e.preventDefault();$('.wrap').toggle();return false;}); // end toggle
}); // end ready
It should work
Upvotes: 0