Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the Documentation for all of the Javascript HTML Element Constructors?

I cannot seem to find it. Thanks!

Example:

$("#MySelect").append(new Option("MyOption", "MyOption", true, true));
like image 287
Guido Anselmi Avatar asked Mar 24 '11 19:03

Guido Anselmi


1 Answers

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

option element reference:

  • HTML <option> element
  • HTMLOptionElement interface (which is implemented by the above)
  • W3C HTMLOptionElement interface spec

Since you're using jQuery, however, there's a better way to construct elements.

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

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

like image 58
Matt Ball Avatar answered Oct 08 '22 14:10

Matt Ball