1. Get the text selected by select:
$ ("#cusChildTypeId"). Find ("option:selected"). Text ();
$ ("#cusChildTypeId option:selected"). Text ()
2. Get the value selected by select:
$ ("#ddlRegType"). Val ();
3. Get the selected index for select:
$ ("#ddlRegType"). Get (0). SelectedIndex;
4. Get the number of select items
$ ("#cusChildTypeId"). Get (0). options.length
5. Set the index selected by select:
$ ("#cusChildTypeId"). Get (0). Selectedindex=index;//index as index value
6. Set the value selected by select:
$ ("#cusChildTypeId"). attr ("value", "Normal");
$ ("#cusChildTypeId"). Val ("Normal");
$ ("#cusChildTypeId"). Get (0). Value = "Normal";
7. Set the text selected by select:
1>.var count=$ ("#cusChildTypeId"). Get (0). Options.length;
for (Var i=0;i<count;i++)
{
if ($ ("#cusChildTypeId"). Get (0). Options.text = = text)
{
$ ("#cusChildTypeId"). Get (0). options.selected = true;
Break
}
}
2>.$ ("#cusChildTypeId"). val (text);
$ ("#cusChildTypeId"). Change ();
8. Add an entry to the select that displays text with a value of
$ ("#cusChildTypeId"). Get (0). Options.add (New Option (Text,value));
9. Delete the item with value in select
var count = $ ("#cusChildTypeId"). Size ();
for (Var i=0;i<count;i++)
{
if ($ ("#cusChildTypeId"). Get (0). Options[i].value = = value)
{
$ ("#cusChildTypeId"). Get (0). remove (i);
Break
}
}
10. Clear the Select:
1>. $ ("#cusChildTypeId"). empty ();
2>. $ ("#cusChildTypeId"). Get (0). options.length = 0;
jquery Get and set select options Common Methods Summary