简体   繁体   English

jQuery按名称选择元素

[英]jQuery selecting elements by name

I have the following html: 我有以下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: 和两个相应的jQuery选择器:

$("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); 特别提醒($(“input [name ='men_url'”)。name); displays "undefined" 显示“未定义”

第二个错过了结束]

also, there's no "name" property. 此外,没有“名称”属性。 Use $(..).attr('name') instead. 请改用$(..).attr('name')

// Pozdrawiam ;) / ["greetings", in polish] ;) // Pozdrawiam;)/ [“问候”,在波兰语中;)

它应该是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM