I’m trying to select the entire document except for a certain div. In my belief the code below should work but it isn’t. Can anyone see what I’m doing wrong?
$(document:not("#test")).bind('keydown',function(e){
switch(e.which) {
case 8:
$("#status").append("<br/>captured");
break;
default:
break;
}
});
HTML to go with:
<textarea id="test" ></textarea><br/>
<input type="text" id="message"/>
<div id="status"></div>
I have also tried several variants of this
//$("*:not(#message)").bind('keydown',function(e){
You are mixing an object (
document) with a jQuery selector (:not("#test")). That makes it invalid syntax, as the selector should be inside a string.If it would have run, you would have selected all document objects (the only one) except the ones with
id="test"(none, as the document object doesn’t have HTML attributes).Perhaps you actually want to select all elements inside the body, except that div?