createElement?

J

JS

The document object has a method called createElement. Can I use this
method to create a new Drop/down list, like:

var sel = document.createElement('SELECT');



I have seen it used like this:

opt = document.createElement('OPTION');

which means that opt now holds an option that can be appended to an already
existing select object.
Are there any restrictions for which arguments createElement can be called
with? I have seen: var oNewNode = document.createElement("LI");but what is
"LI"? Where do I need to look to find valid arguments for createElement??
 
R

Richard Cornford

JS wrote:
... Can I use this
method to create a new Drop/down list, like:

var sel = document.createElement('SELECT');

Yes.

Are there any restrictions for which arguments
createElement can be called with?
Yes.

I have seen: var oNewNode =
document.createElement("LI");but what is "LI"?

If you are not familiar with HTML there is not much point in attempting
to script an HTML DOM.
Where do I need to
look to find valid arguments for createElement??

The Core DOM applies to many document types. In general you can only
create elements that make sense with the document type you are
scripting. In an HTML DOM you create HTML elements so the HTML
specification effectively lists those elements.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top