There are some cases where we need to add dynamically a default value to the dropdowns. A simple code snippet which enters default option to all the dropdown inside a container :
//Used to insert default value for the dropdowns
function InsertFirstOptionToDropdowns(divId) {
//Find all the select and add span
$("#divContainer").find('select').each(function () {
$(this).prepend("<option value='' selected='selected'>Please Select</option>");
});
}
cheers
No comments:
Post a Comment