views:

38

answers:

2

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 second and then dissapear. I want for the div to appear when I click the link, and then dissapear when I click the link again.

+4  A: 

Try this:

  $('.list li a').click(function(e){
     $('.LoginContainer').toggle();
     e.preventDefault();
  });
Jacob Relkin
Yep! that should do it!
Trufa
thanks! this works! mind explaining what the added code does?
Justin Meltzer
A: 

You can Try this

$(document).ready(function() {

     $('.className').click(function(e){
          $('.LoginContainer').toggle();
          e.preventDefault();
     });

}

I agree with e.preventDefault();

Wazzy
@Wazzy, You do realize that this is an exact dupe of my answer?
Jacob Relkin
Ya I agree but I didnt loaded your answer.When I loaded mine I got to know yours and lastly after reading the documentation of e.preventDefault(); I added last line.Infact I appreciate your answer
Wazzy