createElement?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JS

    createElement?

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

    var sel = document.create Element('SELECT ');



    I have seen it used like this:

    opt = document.create Element('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.create Element("LI");b ut what is
    "LI"? Where do I need to look to find valid arguments for createElement??


  • Richard Cornford

    #2
    Re: createElement?

    JS wrote:
    <snip>[color=blue]
    > ... Can I use this
    > method to create a new Drop/down list, like:
    >
    > var sel = document.create Element('SELECT ');[/color]

    Yes.

    <snip>[color=blue]
    > Are there any restrictions for which arguments
    > createElement can be called with?[/color]

    Yes.
    [color=blue]
    > I have seen: var oNewNode =
    > document.create Element("LI");b ut what is "LI"?[/color]

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

    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.


    Comment

    Working...