2014-06-28 15 views

回答

2

本地JavaScript(> = IE 8)

!~[].indexOf.call(document.querySelectorAll("input, textarea"), document.activeElement) 
+0

如果你知道答案,那麼爲什麼要問? –

+0

好問題@Riturajratan!我試圖找到一個回答這個問題的問題,雖然我沒有辦法。然後我想出了一個我自己的解決方案,並決定把它變成一個問題,讓其他人可以受益並享受它。 – theliberalsurfer

+0

所以我認爲你先搜索然後問任何問題的方式歡呼;) –

0

使用:focus

$("input, textarea").is(":focus") 

看到here會很有幫助

相關問題