javacriptまたはjqueryを使用して入力フィールドが選択されているかどうかを確認するにはどうすればよいですか? ?javacriptまたはjqueryを使用して入力フィールドが選択されているかどうかを確認します
任意の助けもいただければ幸いです!ありがとう!
javacriptまたはjqueryを使用して入力フィールドが選択されているかどうかを確認するにはどうすればよいですか? ?javacriptまたはjqueryを使用して入力フィールドが選択されているかどうかを確認します
任意の助けもいただければ幸いです!ありがとう!
いくつかのグーグルが迅速な解決策を見つけました。 http://forums.digitalpoint.com/showthread.php?t=77983
から
組み込みの方法はありません。 onfocusイベントとonblurイベント を使用して、読み込む各要素に何らかのフラグを設定する必要があります。
このスクリプトは、フォームの任意の数のプロセスを自動化します。
コード:
<script type='text/javascript' >
/* (c)2006 Stephen Chalmers
*
* Appends a 'hasFocus' flag to all text/textarea form
* elements.
*
Insert this script anywhere below the last form in the document.
To read the current focus state of a specified element, use:
if(document.forms.myForm.myElement.hasFocus)
...
***/
for(var i=0, df=document.forms, len=df.length; i<len; i++)
for(j=0, els=df[i].elements; j<els.length; j++)
if(/^text/.test(els[j].type))
{
els[j].hasFocus=false;
els[j].onfocus=function(){this.hasFocus=true;};
els[j].onblur =function(){this.hasFocus=false;};
}
</script>
を見たことがありますか? –
選択したことはどういう意味ですか?それは入力にフォーカスがあることを意味しますか? – naveen