[英]Best way to find all input elements inside a form using jQuery
我需要在表單內找到所有表單元素,並在值發生變化時觸發一個標志。 目前我正在使用下面的方法。 我不確定這是否有效。 但它肯定適用於: .find('input[type=text])
$('#form').find('input[type=text], input[type=radio], input[type=checkbox], select, textarea').each(function(){
$(this).change(function(){
if( change !== 1 ) change = 1;
});
})
現在我用逗號添加了多個元素。 這會起作用嗎,這是最好的方法嗎?
感謝所有的幫助。
謝謝!
試試這個:
$('#form').find(':input').each(function(){
$(this).change(function(){
if( change !== 1 ) change = 1;
});
})
檢查文檔@:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.