带有句点的jQuery属性选择器 [英] jQuery Attribute selector with a period
本文介绍了带有句点的jQuery属性选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jQuery选择器来查找具有特定名称的所有输入字段:
I'm trying to use a jQuery selector that finds all input fields with a specific name:
$('input[name=Filter']).click(function() {
// do something
});
这应与以下项目匹配:
<input type="radio" name="Filter" value="A" />
<input type="radio" name="Filter" value="B" />
这很好.我遇到的问题是我的名字是由ASP.net MVC动态生成的,并且名字有句点:
This is working fine. The problem I am having is that my names are dynamically generated by ASP.net MVC and the names have a period:
<input type="radio" name="Parent.Filter" value="A" />
<input type="radio" name="Parent.Filter" value="B" />
我试图编写以下选择器:
I tried to write the following selector:
$('input[name=Parent.Filter]').click(function() {
});
我收到以下错误:
Uncaught Syntax error, unrecognized expression: [name=Parent.Filter]
我如何编写此表达式以使其正常工作?
How can I write this expression so that it works properly?
推荐答案
引号是强制性的,在这种情况下,没有引号就无法工作.
Quotes are mandatory, and in this instance it won't work without them.
$('input[name="Parent.Filter"]').click(function() {
});
值:属性值.引号是强制性的.
value An attribute value. Quotes are mandatory.
这篇关于带有句点的jQuery属性选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文