2013-03-28 55 views
0

所以我放棄了prototype.js幾年和幾年前的jQuery LOL ...現在我發現自己不得不再次使用它,並不能退出如何獲得這個jQuery聲明出prototype.js ...任何人都可以幫忙嗎?Prototype.js測試如果元素有焦點

if(!$('#search').is(':focus')){ 
+1

這是jQuery的檢查它:' 「焦點」:(!document.hasFocus || document.hasFocus())函數(ELEM){返回ELEM === document.activeElement && && !!(ELEM .type || elem.href ||〜elem.tabIndex); }'。很簡單。 – dfsq

+0

非常感謝!......你知道那手牌是怎麼回事嗎?真/假或者什麼? (document.hasElement &&(!document.hasFocus || document.hasFocus())&& !!($('search')。type | – Banning

+0

)看起來像它返回true/false這是我使用你給我的新腳本if | $('search').href ||〜$('search').tabIndex)!= true){ – Banning

回答

0

我的問題的答案是由Pointy的評論解決的...這是我最終的解決方案,任何人都可能需要它。

if($$('#search:focus') == ''){ 
+1

try'$$('#search:focus')。length == 0' –