开发者

How to get selectbox value with name [duplicate]

开发者 https://www.devze.com 2023-03-31 18:52 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: Get开发者_Go百科 form elements by name?
This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

Get开发者_Go百科 form elements by name?

Here's a link i can't get it to work: http://jsfiddle.net/PwfzR/3/


Try this.

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


have a look at attribute selectors

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

here is the fiddle http://jsfiddle.net/PwfzR/


This is more specific and matches <input type="text"> elements only:

$('input[type="text"][name="box"]');

Of course, if you don't want to restrict your matches to type="text", you can use the following code, as scunliffe mentions:

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


Your problem is that you had input instead of select. Here, I'll post the corrected code. Tell me if this works:

 $("select[name='selectbox']").change(function() {
 alert('t');
 }); 


$('input[name$="box"]').val();

See the full documentation here: http://api.jquery.com/attribute-ends-with-selector/


If you already know the name of the element just prepend # to the name to select it.

$('#box') this will work for any named element.

0

精彩评论

暂无评论...
验证码 换一张
取 消