0

I'm trying to remove the css when somewhere on the page has been clicked. I know how to implement the css changes but can't figure out how to or where to place the listener for a mouse click.

Any suggestions would be great.

$(document).ready(function() {
    var friends = false;
$('#friends').click(function() {
    friends = true;
    $('#cont').css({'left':'502px'}); 
        $('#members').css({'left':'251px','display':'inline','opacity':'1'});
    alert(friends);
});

if($(document).click() && friends){
    alert('here');
};
});
nanobash
  • 5,419
  • 7
  • 38
  • 56
Steveo
  • 557
  • 4
  • 15

1 Answers1

0

Got it working eventually using this but modified it alot:

jQuery().ready(function(){
$('#nav').click(function (event) {
    $(this).addClass('activ');
    event.stopPropagation();
});

$('html').click(function () {
    if( $('#nav').hasClass('activ') ){
        $('#nav').removeClass('activ');
    }
});

});

Steveo
  • 557
  • 4
  • 15