获取位于特定类中的所有文本字段值 [英] Get all text field value located in a specific class

查看:89
本文介绍了获取位于特定类中的所有文本字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取位于单个类名中的所有字段..例如我的代码.

I want to get all fields that are located in a single class name .. for example my code like.

<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>

我想获取each loop,它在其中返回给我位于此类中的文本字段值. 有什么建议 .. (我是jquery的新手)

i want to get the each loop in which it return me the text fields value that is located in this class.. Any suggestions .. (i am new in jquery)

推荐答案

尝试一下:

$(".test .text-field")

要获取价值,请尝试以下操作:

To get values try this:

$(".test .text-field").each(function() {
    alert($(this).val());
});

这篇关于获取位于特定类中的所有文本字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆