trying to hide/show div with jquery by clicking one link
here's my js:
$(document).ready(function() {
$('.LoginContainer').hide();
$('.list li a').click(function(){
$('.LoginContainer').toggle();
});
});
This only makes the div with class="loginContainer" appear for a split se开发者_StackOverflow社区cond and then dissapear. I want for the div to appear when I click the link, and then dissapear when I click the link again.
Try this:
$('.list li a').click(function(e){
$('.LoginContainer').toggle();
e.preventDefault();
});
You can Try this
$(document).ready(function() {
$('.className').click(function(e){
$('.LoginContainer').toggle();
e.preventDefault();
});
}
I agree with e.preventDefault();
精彩评论