Some basic operations of Jquery, basic operations of Jquery
/* Obtain the value of TEXT. AREATEXT */
Var textval = $ ("# text_id"). attr ("value ");
// Or
Var textval = $ ("# text_id"). val ();
/* Obtain the value of the single-choice button */
Var valradio = $ ("input [@ type = radio] [@ checked]"). val ();
/* Obtain the value of a set of radio selected items named (items */
Var item = $ ('input [@ name = items] [@ checked] '). val ();
/* Obtain the value of the check box */
Var checkboxval = $ ("# checkbox_id"). attr ("value ");
/* Get the value of the drop-down list */
Var selectval = $ ('# select_id'). val ();
// Text box, text area:
$ ("# Text_id"). attr ("value", ''); // clear the content
$ ("# Text_id"). attr ("value", 'test'); // fill in the content
// Multiple choice box checkbox:
$ ("# Chk_id"). attr ("checked", ''); // make it unchecked
$ ("# Chk_id"). attr ("checked", true); // select
If ($ ("# chk_id"). attr ('checked') = true) // you can check whether the selected
// Single-choice group radio:
$ ("Input [@ type = radio]"). attr ("checked", '2'); // set the project with value = 2 to the selected one
// Select from the drop-down list:
$ ("# Select_id"). attr ("value", 'test'); // set the project with value = test as the selected item
$ ("<Option value = 'test'> test </option> <option value = 'test2'> test2 </option> "). appendTo ("# select_id") // Add the option in the drop-down box
$ ("# Select_id"). empty (); // clear the drop-down list
Obtains the value of a set of radio selected items named (items ).
Var item = $ ('input [@ name = items] [@ checked] '). val (); // if not selected, val () = undefined
Obtain the text of the selected select item.
Var item = $ ("select [@ name = items] option [@ selected]"). text ();
The second element in the select drop-down box is the selected value.
$ ('# Select_id') [0]. selectedIndex = 1;
The second element of the radio Group is the currently selected value.
$ ('Input [@ name = items] '). get (1). checked = true;
// Reset the form
$ ("Form"). each (function (){
. Reset ();
});