In this post, you will find various ways to reset the dropdown using jQuery. These are one line of jQuery code, which can reset the dropdown.
Below code will find the first item in the list and make it selected.
Also read "Common Dropdown operation (Get, Set, Add, Remove) using jQuery"
Feel free to contact me for any help related to jQuery, I will gladly help you.
Below code will find the first item in the list and make it selected.
$('#DropDownList1').find('option:first').attr('selected', 'selected');Below code will find the item with value o and selects it. If the first item in your dropdown list starts with -1, then use -1 as argument.
$('#DropDownList1').val(0);Below jQuery code will set the very first item of the list as selected.
$('#DropDownList1 option:eq(0)').attr('selected','selected');Below jQuery code will set selectedindex of dropdown list to 0, which is the first item of the dropdown list.
$('#DropDownList1').get(0).selectedIndex = 0;If you know any other way to reset the dropdown then please let us know. We will add your code in this list and also give credit you for the same.
Also read "Common Dropdown operation (Get, Set, Add, Remove) using jQuery"
Feel free to contact me for any help related to jQuery, I will gladly help you.
No comments:
Post a Comment