I need a jquery help in click to to hide issue .
What I have now :
I have a text I can click and it will open div . And when I click any place this div hides .also when I click the Gray div still it's hide
*What I am trying *
I am trying to limit the hiding . IF I click on the Div it should not hide . beside that clicking other places It will hide .
Live js Fiddle demo: http://jsfiddle.net/S4hcf/
HTML
<p class="show_hide">Clcik Me</p>
<div class="slidingDiv"></div>
CSS
div{
width:200px;
height:150px;
background:#ccc;
}
p{
cursor:pointer;
}
jQuery
// click to hide
$('html').click(function(event){
if($('.slidingDiv').is(':visible')){
$('.slidingDiv').hide();
}
});
//Toggle
$(".slidingDiv").hide();
$('.show_hide').click(function(event){
event.stopPropagation();
$(".slidingDiv").slideToggle();
});
Any help will be appreciated . Thanks