2011-12-20 32 views
0

不同我有一個像jQuery代碼:jQuery的IsFocus導致的Safari和其他瀏覽器

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

現在的Safari瀏覽器顯示的信息真實,其他瀏覽器顯示信息錯誤,當我在文本框中書寫。

任何幫助表示讚賞

+0

重複http://stackoverflow.com/questions/2683742/is-there-a-has-focus-in-javascript-or-jquery – scottheckel 2011-12-20 14:14:47

+0

@Hexxagonal我不認爲這是。此問題描述了特定瀏覽器的特定問題。您鏈接的問題早於':focus'選擇器並且不再準確。 – Blazemonger 2011-12-20 14:25:07

+0

我沒有意識到1.6和更高版本中已添加。涼。 – scottheckel 2011-12-20 14:30:47

回答

0

使用this jsFiddle我測試了它在Internet Explorer 9

工作望着jQuery的錯誤,我發現有一個jQuery or Chrome bug which causes it to fail on that platform。在我的Chrome版本中測試也失敗了。

我沒有使用FireFox測試,因爲jQuery的bug說明它在那裏工作。你已經說過它適用於Safari。我猜你的「其他瀏覽器」是Chrome。

+0

它不適用於safari,因爲代碼alert(!$('#txtSearchTextBox')。is(「:focus」));必須返回false,但它是returing虛假的,所以問題是與safari而不是其他人,鉻工作正常 – Moons 2011-12-21 04:17:41

相關問題