kubal5003
kubal5003

Reputation: 7254

jQuery selecting elements by name

I have the following html:

<td valign="top" align="left"> <input style="width:250px;" name="men_url" type="text" /></td>


<td valign="top" align="left"> 
<select name="men_page">
 <option value="">Wybierz stronę</option>
 <option value="index.php?page=8">O firmie</option>
 <option value="index.php?page=9">Referencje</option>

</select>
</td>

and two corresponding jQuery selectors:

$("select[name='men_page']")

and

$("input[name='men_url']")

The first one works great, the second one returns nothing. What might be wrong here?

Especially alert($("input[name='men_url'").name); displays "undefined"

Upvotes: 4

Views: 153

Answers (3)

migajek
migajek

Reputation: 8614

also, there's no "name" property. Use $(..).attr('name') instead.

// Pozdrawiam ;) / ["greetings", in polish] ;)

Upvotes: 3

Tobias P.
Tobias P.

Reputation: 4664

it should be

$("input[name='men_url']")

Upvotes: 1

rosscj2533
rosscj2533

Reputation: 9323

The 2nd one is missing the closing ]

Upvotes: 8

Related Questions