[jQuery] click on one div to show another div, click anywhere else hide this div
I've already got the first part of this working:
$(function(){
$('div#rightShoppingCartButton').click(function(){
showCart(this);//Shopping cart div has been clicked
});
});
function showCart(div){
var rsccb = "#rightShoppingCartContainsBox";
if($(rsccb).css('display') == "none") {
$(rsccb).css("display",'inline');
}
}
But, I don't know how to made the div disappear when the user clicks
anywhere else.
Here's what I've tried that doesn't work:
$("body").click(function(){
hideCart(this);
});
function hideCart(div){
var rsccb = "#rightShoppingCartContainsBox";
$(rsccb).css("display",'none');
}
Anyone care to help me please?