I am trying to make a simple dropdown using jQuery which opens on mouse click and closes on mouse click or a click over the document. I have the following JS code to make that work. Refer to my code at http://jsfiddle.net/4mCsy/1/ .But the code is not working :-
var x=0;
if(x==0){
$(".notification").click(function(){
$(".drpdwn").css("display","block");
});
x=1;
}
if(x==1){
$(".notification").click(function(){
$(".drpdwn").css("display","none");
});
x=0;
}
But, when I change the code to the following(removing the lower portion of the code) (http://jsfiddle.net/4mCsy/2/), the code partly works in just openiing the dropdown. But does not closes (OBVIOUSLY):-
var x=0;
if(x==0){
$(".notification").click(function(){
$(".drpdwn").css("display","block");
});
x=1;
}
Please tell me where am I going wrong. Any help will be appreciated.