0

I'd like to find all the inputs that have at the end of their names the keyword [0]. I guess I have to use the following method:

$("input[name=name]")

But how to specify only a part of the name?

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55

3 Answers3

1

Might be you want this

$("input[name$=name]");

Select all elements with a name attribute value ending with name.

Check Manual

Community
  • 1
  • 1
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
0

Use jQuery's Attribute Ends With Selector ($=) to match things at the end of the attribute:

$("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.

If you want to match input elements whose name attribute ends in "[0]", you'd use:

$("input[name$='[0]']")
James Donnelly
  • 126,410
  • 34
  • 208
  • 218
0

Might be you want this Check the manual here

$( "input[name$='letter']" );

or

$("input[name^='name[']");
I'm Geeker
  • 4,601
  • 5
  • 22
  • 41