Can't get jQuery :not selector to work -
if type character inside input field of jsbin below, div slide down. on click of elements other div.wrap , children, want div slide up. can not seem right. keeps doing opposite of want.
http://jsbin.com/sobecume/1/edit?html,css,js,console,output
js
$('.blah').keyup(function(){ $('.blah2').slidedown(); }); $('body:not("#wrap")').click(function(){ console.log("click!"); var display = $('.blah').css('display'); if (display !== 'none') { $('.blah2').slideup(); } });
i don't think can craft selector check against element's ancestors (i think?).
try this:
$('*').click(function(){ if($(this).closest('#wrap').length>0){return false;} console.log("click!"); var display = $('.blah').css('display'); if (display !== 'none') { $('.blah2').slideup(); } });
Comments
Post a Comment