我想获取位于单个类名中的所有字段,例如我的代码。
<div class="test">
<input type="text" class="text-field" />
<input type="text" class="text-field" />
<input type="text" class="text-field" />
<input type="text" class="text-field" />
</div>
<div class="test">
<input type="text" class="text-field" />
<input type="text" class="text-field" />
<input type="text" class="text-field" />
<input type="text" class="text-field" />
</div>
我想要获取每个循环
,其中它返回位于此类中的文本字段值。有什么建议吗?
最佳答案
试试这个:
$(".test .text-field")
编辑:
要获取值,请尝试以下操作:
$(".test .text-field").each(function() {
alert($(this).val());
});
关于jquery - 获取位于特定类中的所有文本字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6758301/