Share the next jquery how to set the Get drop-down menu for an option value, a variety of methods, worth collecting.
jquery Get and set select options
Get select:
Gets the text selected by the Select:
$ ("#ddlRegType"). Find ("option:selected"). Text ();
Gets the value selected by select:
$ ("#ddlRegType"). Val ();
Gets the index selected by the Select:
$ ("#ddlRegType"). Get (0). SelectedIndex;
Set Select:
To set the index selected by select:
$ ("#ddlRegType"). Get (0). Selectedindex=index;//index sets the value of select selected for index values
:
$ ("#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)
{//www.jbxue.com
$ ("# Ddlregtype "). Get (0). options[i].selected = true;
break;
}
}
Empty Select:
$ ("#ddlRegType"). empty ();