haeki
haeki

Reputation: 152

Jquery if input not focused not working

i binded some keys via .keypress() but they should not be binded if one of my input fields is focused so I googled a bit and found that Using jQuery to test if an input has focus

I don't know what I'm doing wrong but I don't get this working.

-> http://jsfiddle.net/DzAwn/10/

$(document).ready(function() {
if (!($("input").is(":focus"))) {
    alert('not focused');
}

});

There should be a workaround with variables and .focus(), but I think the way I tried is the easiest, if it's working....

Need your help! :)

Upvotes: 3

Views: 16874

Answers (1)

rauberdaniel
rauberdaniel

Reputation: 1033

You didn't include jQuery (upper select box in left sidebar). It should work then.

Upvotes: 2

Related Questions