I am trying to add an element to a dropDown and after selection remove it, by naively trying to have htmlElement refrence defines as such : (Of course this doeasnt work)
var selectAnOption = "<option value='' selected='selected'>Select One</option>";
So later
var addSelectAnOption = function () { ('#ddb1').prepend(selectAnOption ); };
var removeSelectAnOption = function () { selectAnOption.remove(); };
I have also tried the following variation:
var selectAnOption;
var addSelectAnOption = function () { selectAnOption = $('#ddb1').prepend("<option value='' selected='selected'>Select One</option>"); };
var removeSelectAnOption = function () { selectAnOption.remove(); };
But this also didn't work, as selectAnOption was set to the dropDownBox itself
Of course I could add the option with an id and then later use that to find it to remove it, but that seemed not too pretty.
optionis ever selected at one time, you could use$('option[selected="selected"]').remove();