查找具有特定关键字的所有输入
Find all input with specific keyword
我想找到名称末尾有关键字 [0]
的所有输入。我想我必须使用以下方法:
$("input[name=name]")
但是如何只指定名字的一部分呢?
使用jQuery的Attribute Ends With Selector ($=
)来匹配属性末尾的东西:
$("input[name$='name']")
Description: Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.
如果要匹配 input
属性以 "[0]"
结尾的 name
元素,您将使用:
$("input[name$='[0]']")
也许你想要这个
$("input[name$=name]");
Select all elements with a name attribute value ending with name
.
也许你想要这个
Check the manual here
$( "input[name$='letter']" );
或
$("input[name^='name[']");
我想找到名称末尾有关键字 [0]
的所有输入。我想我必须使用以下方法:
$("input[name=name]")
但是如何只指定名字的一部分呢?
使用jQuery的Attribute Ends With Selector ($=
)来匹配属性末尾的东西:
$("input[name$='name']")
Description: Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.
如果要匹配 input
属性以 "[0]"
结尾的 name
元素,您将使用:
$("input[name$='[0]']")
也许你想要这个
$("input[name$=name]");
Select all elements with a name attribute value ending with
name
.
也许你想要这个 Check the manual here
$( "input[name$='letter']" );
或
$("input[name^='name[']");