0

I have a jquery code like:

alert(!$('#txtSearchTextBox').is(":focus"));

Now the safari shows the message true and the other browsers show the message false when i write in the textbox.

Any help is appreciated

Moons
  • 3,833
  • 4
  • 49
  • 82
  • Duplicate of http://stackoverflow.com/questions/2683742/is-there-a-has-focus-in-javascript-or-jquery – scottheckel Dec 20 '11 at 14:14
  • @Hexxagonal I don't think it is. This question describes a specific issue with a specific browser. The question you linked to predates the `:focus` selector and is no longer accurate. – Blazemonger Dec 20 '11 at 14:25
  • I didn't realize that was added in 1.6 and up. Cool. – scottheckel Dec 20 '11 at 14:30
  • @Hexxagonal I am using jquery 1.7+ and it has a focus selector. Check this link too http://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus. And please read the question before commenting it as duplicate – Moons Dec 20 '11 at 14:35
  • Yeah, I did. That's why I linked to something that creates an is(":focus") implementation and then afterward said I didn't realize that was added in 1.6. – scottheckel Dec 20 '11 at 14:53

1 Answers1

0

Using this jsFiddle I tested it as working in Internet Explorer 9.

Looking at the jQuery bugs, I found that there is a jQuery or Chrome bug which causes it to fail on that platform. Testing in my version of Chrome it also fails.

I did not test with FireFox as the jQuery bug stated it worked there. And you already said it works for Safari. I'm guessing your "other browsers" was Chrome.

scottheckel
  • 9,106
  • 1
  • 35
  • 47
  • It is not working for safari as the code alert(!$('#txtSearchTextBox').is(":focus")); must return false but it is returing false so problem is with safari and not others and chrome is working fine – Moons Dec 21 '11 at 04:17