2013-03-28 58 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' –