Where is the documentation for all Javascript HTML element constructors located?

I can not find him. Thank!

Example:

$("#MySelect").append(new Option("MyOption", "MyOption", true, true)); 
+4
javascript html browser
Mar 24 '11 at 19:39
source share
4 answers

The Mozilla Dev Center is the de facto standard documentation site for all JavaScript.

option link to an element:




Since you are using jQuery, the best way to create elements .

 $('#MySelect').append('<option></option>', { text: 'MyOption', value: 'MyOption', selected: true }) 

I'm not sure what should make the last argument true - at least in Chrome, new Option('text', 'value', true, true) seems to return the same thing as new Option('text', 'value', true) .

+5
Mar 24 '11 at 19:41
source share

None of the current posts answer the question about getting "... Documentation for ALL Javascript HTML element constructors." This example explicitly uses the constructor "... a new variant ...".

This "answer" contains links that do not define any constructors, such as new Option() .

the DOM link provided should have defined the Option() constructor, or at least referenced it.

The programmed Option() constructor is NOT HTML and therefore is NOT defined by the other two links that describe the HTML. The element of the <OPTION> is an HTML marked marker, therefore, presumably only using an implicit use-case, new Option() is the corresponding equivalent constructor that absorbs the attributes of the <OPTION> properties similar to other dynamic constructs, but where it is formally, explicitly and strongly stated to define new Option() ? In particular, the type and order of the new Option() parameters will be defined in such a document.

Although not a constructor, the createElement() document method is well defined ( https://developer.mozilla.org/en/DOM/document.createElement ). Using document.createElement("option") with HTMLOptionElement links in this "answer" fully defines such a construct.

An archaic document that initiated a legacy of entangled paradigms between DOM, HTML, and javascript defines new Option() here , but in the modern context it is inadequate.

+3
Aug 03 2018-11-11T00:
source share

If you do not know / cannot find this document, you can try using HTML if you know this.

 $("#MySelect").append("<option value='myValue'>MyValue</option>"); 

or

 $("#MySelect").append("<option value='myValue' selected>MyValue</option>"); 
+1
Mar 24 '11 at 19:41
source share

The syntax you have looks like jQuery - doesn't it? If so, then append takes an HTML string. You do not need to subclass HTMLElement for it.

This link from Mozilla will be helpful in understanding HTML DOM elements.

This site provides javadoc style documentation for the HTMLElement class and its subclasses.

+1
Mar 24 '11 at 19:43
source share



All Articles