I have a div which when clicked shows a contact us
form .
That is, on toggle it shows and hides. How can I make it to hide on clicking from other part of document.
The code is below
function showCctFrm(){
var frmWidth = '-40';
$("#quick_cct_form").toggle(function(e){
if($("#quick_cct_form").is(":visible")){ frmWidth = "200"; }
if($("#quick_cct_form").is(":hidden")){ frmWidth = "-40"; }
$("#fixed_cct_us").css("right",frmWidth+"px");
//e.stopPropagation();
});
//alert(frmWidth);
}
I tried this to hide on clicked outside:
$(document).click(function(e) {
if(e.target.id != 'fixed_cct_us') {
$("#quick_cct_form").hide();
$("#fixed_cct_us").css("right","-40px");
}
});
the HTML div for that is as below
<div id="fixed_cct_us" style="right: 240px;">
<a title="connect" href="javascript: showCctFrm();">connect </a>
</div>