0

I am using jQuery to make a div hide if a different div is clicked:
js:

$("body").click(function(){
   if( $(this).attr('class') == 'not-dropdown'  ){

         $(".dropdown").hide();

}

});

Before I tried this:

$("body").click(function(){
   if( 1==1  ){

         $(".dropdown").hide();
   }

});

Then the div hid, but no matter where I clicked the div hid. How can I make the div only hide when it is a certain element that is clicked?
Fiddle

yaakov
  • 4,568
  • 4
  • 27
  • 51
  • well, no, because i can't assume people will click on a div specifically. – yaakov Jun 01 '15 at 17:29
  • @Vohuman, i searched for this and didn't find it, so I asked it. this is not a duplicate – yaakov Jun 01 '15 at 17:29
  • this is what you want http://jsfiddle.net/ba56srhg/6/ – AmmarCSE Jun 01 '15 at 17:30
  • body means relatively the whole "seen" document already. That's why it doesn't matter where you click. 'this' means the element you are passing the function. In your case it is body. Your statement won't work unless your body has a class. – Litestone Jun 01 '15 at 17:32
  • I believe this is a duplicate question. Don't you want to hide a specific element when you user clicks outside of it? i.e." if a different div is clicked"? – Ram Jun 01 '15 at 17:32
  • yes, but i tried seven different answers and none of them worked. [here](http://sarkelliancreed.comule.com) is where the page is. – yaakov Jun 01 '15 at 19:51
  • Click the nav bar on the top of the page. There are supposed to be dropdowns. – yaakov Jun 01 '15 at 19:54

0 Answers0