Removing A Option From Dropdownlist Item With Jquery
I have a situation where in some cases a dropdownlist can contain a default value that is not selectable, once another value is changed, the default value should no longer be an op
Solution 1:
Assuming your HTML is like this
<select id="dd"class="valueSkippedHyperSwap">
<option value="^">None</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
The below script should remove item with value ^
if any other options are selected
$(function(){
$('.valueSkippedHyperSwap').change(function () {
var item=$(this);
if(item.val()!="^")
{
item.find("option[value='^']").remove();
}
});
});
JsFiddle Sample http://jsfiddle.net/He5gP/10/
Post a Comment for "Removing A Option From Dropdownlist Item With Jquery"