createElement() Method in JavaScript is used to create a HTML element dynamically.
lets take an example:
var select = document.getElementById("selectbox"); //1
var option = document.createElement('option');
option.text = "XYZ";
select.add(option);
the "selectbox" is the Tag name in statement 1 that define the HTML element to be created. for the same purpose the createElement() is used. In a larger scale we can make option in the select box using the same method as done in above.
0 Comment(s)