Remove Specific Items From Dropdown List Using Jquery
I have a multi select dropdown list. I can get the array of selected values using: selectedItems = $('#myList').val(); // works. Now, how can I remove the selected items from t
Solution 1:
$("#myList option:selected").remove();
Edit: I misunderstood the comment, but I will leave it as an example for removing certain elements in general. If you want to remove the elements based on the value in the array, you have to loop over the array:
var $list = $("#myList"),
toRemove = $();
for(var i = selectedItems.length; i--;) {
toRemove = toRemove.add($list.find('option[value="' + selectedItems[i] + '"]'));
}
toRemove.remove();
Solution 2:
This could help you:- Remove Selected Option using jQuery
Solution 3:
$("[Id$='ddlShowRun'] option:selected").remove();
Post a Comment for "Remove Specific Items From Dropdown List Using Jquery"