How to realize RadioButton,input,CheckBox value assignment in jQuery
This article mainly shows you "how to achieve RadioButton,input,CheckBox value assignment in jQuery", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve RadioButton,input,CheckBox value assignment in jQuery" this article.
1. Jquery gets the radio group radio
$("input [name = 'name']: checked") .val ()
2. Jquery gets the next value of radiobutton
("input [name = 'name']: checked") .next () .text ()
$("input [name = 'name']: checked") .val ()
3. Jquery gets the value of input
('# id'). Val ()
4. Jquery judgment checkbox checkbox
$("# id:checkbox") .attr ("checked")
Take a value of $("# id") .attr ("value")
The value is assigned directly in text () and val ().
How does JQUERY get text,areatext,radio,checkbox, select values?
("input") .val ()
("textarea") .text ()
("select") .val ()
Control form elements:
Text box, text area: $("# txt") .attr ("value",''); / / clear the content
$("# txt") .attr ("value", '11'); / / fill the content
Check box checkbox: $("# chk1") .attr ("checked",'); / / do not check
$("# chk2"). Attr ("checked", true); / / check
If ($("# chk1"). Attr ('checked') = = undefined) / / determine whether it has been checked
Select group radio: $("input [@ type=radio]") .attr ("checked",'2'); / / set the project of value=2 as the currently selected item
Drop-down box select: $("# sel") .attr ("value",'- sel3'); / / set the project of value=-sel3 as the currently selected item
$("11112222"). AppendTo ("# sel") / / add the option of the drop-down box
$("# sel"). Empty (); / / clear the drop-down box
JQuery gets and sets the value of the select drop-down box article classification: .net programming
Get Select:
Get the text selected by select:
$("# ddlRegType"). Find ("option:selected"). Text ()
Get the value selected by select:
("# ddlRegType") .val ()
Get the index selected by select:
$("# ddlRegType") .get (0) .selectedIndex
Set up the select:
Set the index selected by select:
$("# ddlRegType"). Get (0). SelectedIndex=index;//index is the index value
Set the value selected by select:
("# ddlRegType") .attr ("value", "Normal")
$("# ddlRegType") .val ("Normal")
$("# ddlRegType"). Get (0). Value = value
Set the text selected by select:
Var count=$ ("# ddlRegType option") .length
For (var iTuno Bandi)