1. Get the selected item:
Get the Value of the selected item :
$('select#sel option:selected').val();
or
$('select#sel').find('option:selected').val();
Get the Text value of the selected item:
$('select#seloption:selected').text();
or
$('select#sel').find('option:selected' ).text();
2. Get the index value of the currently selected item:
$('select#sel').get(0).selectedIndex;
3. Get the maximum index value of the current option:
$('select#sel option:last').attr( "index")
4. Get the length of DropdownList:
$('select#sel')[0].options.length;
or
$('select#sel').get(0).options.length;
5. Set the first option to the selected value:
$('select#sel option:first').attr('selected','true')
or
$('select#sel')[0].selectedIndex = 0;
6. Set the last option to the selected value:
$('select#sel option:last).attr('selected','true')
7. Set any option to be selected based on the index value Value:
$('select#sel')[0 ].selectedIndex = index value; index value = 0,1,2....
8. Set the option of Value=4 to the selected value:
$('select#sel').attr('value','4');
Or
$("select#sel option[value='4']").attr('selected', 'true');
9. Delete option with Value=3 :
$("select#sel option[value=' 3']").remove();
10. Delete which option:
$(" select#sel option ").eq(index value).remove(); index value=0,1,2....
For example, delete the third Radio:
$(" select#sel option ").eq(2).remove();
11. Delete the first option:
$(" select#sel option ").eq(0).remove ();
or
$("select#sel option:first").remove();
12. Delete the last option:
$("select#sel option:last").remove();
13. Delete dropdownlist:
$( "select#sel").remove();
14. Add an option after select:
$("select#sel").append("f");
15. Add an option in front of select:
$("select#sel").prepend("0");
16. Traverse options:
$(' select #sel option ').each(function (index, domEle) {
//Write code
});