送信クリック後にテキストボックスをクリアしたい。
私はこのコードを試しました:
$("#btn").live('click',function(){
$(this).parents('productinstallation').find('input[type="text"],input[type="email"]').val('');
});
しかし、それは機能していません。それを行う別の方法はありますか?
これを試して:
$("#btn").click(function(){
$(this).parents('productinstallation').find('input[type="text"],input[type="email"]').val('');
});
まだあります:
入力に ID またはクラスを割り当てます。例: id=tbEmail
次に、これを使用します。
$("#tbEmail").val("");
または完全な形式の場合:
$(this).closest('form').find("input[type=text], textarea").val("");
.live
jQuery メソッドはバージョン 1.9 で削除されました。使用している jQuery のバージョンによっては、このlive
方法が機能しない場合があります。on
メソッドを使用してみるか、click
$("#btn").on('click',function(){
$(this).parents('productinstallation').find('input[type="text"],input[type="email"]').val('');
});
それらにIDを割り当ててみてください。
$("#btn").live('click',function(){
$(selector).val('');
});