Obtain select:
Obtain the selected text in the SELECT statement:
$ ("# Ddlregtype"). Find ("option: Selected"). Text ();
Obtain the value selected by the SELECT statement:
$ ("# Ddlregtype"). Val ();
Obtain the index selected by the SELECT statement:
$ ("# Ddlregtype"). Get (0). selectedindex;
Set select:
Set the index selected by select:
$ ("# Ddlregtype"). Get (0). selectedindex = index; // index indicates the index value.
Set the value selected by select:
$ ("# Ddlregtype"). ATTR ("value", "normal");
$ ("# Ddlregtype"). Val ("normal ");
$ ("# Ddlregtype"). Get (0). value = value;
Set select selected text:
VaR COUNT = $ ("# ddlregtype option"). length;
For (VAR I = 0; I <count; I ++)
{If ($ ("# ddlregtype"). Get (0). Options [I]. Text = text)
{
$ ("# Ddlregtype"). Get (0). Options [I]. Selected = true;
Break;
}
}
$ ("# Select_id option [TEXT = 'jquery ']"). ATTR ("selected", true );
Set select option items:
$ ("# Select_id"). append ("<option value = 'value'> text </option>"); // Add an option
$ ("# Select_id"). prepend ("<option value = '0'> select </option>"); // insert an option
$ ("# Select_id option: Last"). Remove (); // Delete the option with the largest index value
$ ("# Select_id option [Index = '0']"). Remove (); // delete an option with an index value of 0
$ ("# Select_id option [value = '3']"). Remove (); // delete an option with a value of 3
$ ("# Select_id option [TEXT = '4']"). Remove (); // delete an option with a text value of 4
Clear select:
$ ("# Ddlregtype"). Empty ();