复选框的jQuery选择器,其名称属性中包含某些文本 [英] jQuery selector for a checkbox that contains certain text in its name attribute

查看:76
本文介绍了复选框的jQuery选择器,其名称属性中包含某些文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在jQuery中找到一个选择器,该选择器选择所有复选框输入,它们的名称包含特定的单词,例如"top"或"Top".麻烦选择其他复选框.

I'm trying to find a selector in jQuery that select all inputs that are checkboxes and their name contains a specific word like "top" or "Top". Having trouble b/c its selecting other checkboxes.

是否可以使用类似的东西:

Is it possible to use something like:

$("input[name*='top'] type:checkbox").each etc?

Top 1<input type="checkbox" name="Top1" /><br />
Top 2<input type="checkbox" name="Top2" /><br />
Top 3<input type="checkbox" name="Top3" /><br />
Top 4<input type="checkbox" name="Top4" /><br />

Bottom 1<input type="checkbox" name="Bottom1" /><br />
Bottom 2<input type="checkbox" name="Bottom1" /><br />
Bottom 3<input type="checkbox" name="Bottom1" /><br />
Bottom 4<input type="checkbox" name="Bottom1" /><br />

我只想选择在名称中包含"top"一词的复选框.

I only want to select the check boxes which contian the word "top" in its name.

推荐答案

您已经关闭...

$("input[type='checkbox'][name^='Top']").each()

jsFiddle演示

这篇关于复选框的jQuery选择器,其名称属性中包含某些文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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