Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
フォームがあり、フォームの入力数を知りたいです。
私は次のようにアクセスしようとしています:
alert($(this).parents("form").(':input').size());
この関数がフォームのボタンクリックから呼び出される場合、を使用してページから正しいフォームを取得します。特定のフォーム.parents()を使用するなど、入力へのハンドラーが必要です。$('input').size()
.parents()
$('input').size()
誰かがここで私を助けることができますか?
そのform要素の入力数をカウントするには、次の操作を実行できます。
form
$(this).parents("form").find('input').length
参照:
$(this).parents("form:input").length
これを試して:
alert($(this).parents('form :input').length);