Sunday, May 24, 2009

Fire Fox options.remove issue

Using document.getElementById(elementID).options.remove(0); in order to remove the option from "drop down" in java script. It support only IE browsers and not Fire Fox.

For Fire Fox use DOM1+ methods, which in this case is removeChild(), or the DOM0 method.

or
document.getElementById(elementID).remove(0); // it also supports

Example

objSelect.options.remove(objSelect.length - 1); //support IE only
objSelect.remove(objSelect.length - 1); // Support all browsers

Here objSelect is the dropdown.

No comments:

Post a Comment