Intention:
- On click of (#clickme) a DIV slides down and comes into view and (var isclicked = true)
- When (var isclicked = true) and on click of (#clickme), DIV slides up and (var isclicked = false)
- While (var isclicked = true) and DIV is in view, on click of $('html') slides the DIV up and (var isclicked = false)
Issue: While DIV is in the slideDown position, (var isclicked = true), on click of $('html') keeps firing. What am I missing so that on click o f $('html') only fires WHILE DIV is (var isclicked = true)
var isclicked = false;
$('#clickme').click(function(event){
doslider();
console.log(isclicked);
if(isclicked == true){
$('html').click(function(event){
console.log('is box opened? '+isclicked);
});
}
});
function doslider(){
if(isclicked == false){
$('#myslider').slideDown('slow');
isclicked = true;
}else{
$('#myslider').slideUp('slow');
isclicked = false;
}
return isclicked; }
JSFiddle: http://jsfiddle.net/7Zfwx/92/