empty a select input using js
// Fast javascript function to clear all the options in an HTML select element
// Provide the id of the select element
// References to the old <select> object will become invalidated!
// This function returns a reference to the new select object.
function ClearOptionsFast(id)
{
var selectObj = document.getElementById(id);
var selectParentNode = selectObj.parentNode;
var newSelectObj = selectObj.cloneNode(false); // Make a shallow copy
selectParentNode.replaceChild(newSelectObj, selectObj);
return newSelectObj;
}
// This is an alternative, simpler method. Thanks to Victor T.
// It does not appear to be as fast as the ClearOptionsFast method in FF 3.6.
function ClearOptionsFastAlt(id)
{
document.getElementById(id).innerHTML = "";
}
Also in JavaScript:
- read data from url node js
- javascript try catch finally
- how to trigger events when the document loads in js
- javascript data structures
- weakset in es6
- how to create json file in android programmatically
- what is react native
- javascript array.find
- react native function
- js obj
- how to add script before </body> in magento 2
- javascript default function parameter value
- how to set text for label in jquery
- Node Sass could not find a binding for your current environment
- find max value in javascript
- gatsbyjs shop flotiq
- javascript detect time on page
- shuffle json array javascript
- javascript show 2 decimal places
- react js documentation
- first duplicate javascript
- js add data in object
- redirect users to anmother page in javascript
- compare date and time in js