Javascript variable property list

Where can I find a list of all available methods for variables in Javascript?

For example:

var Variable1 = document.getElementById("Button1");
var Variable2 = document.getElementById("Label1");
var Variable3 = document.getElementById("TextBox1");

      

What are the properties of Variable1, Variable2 and Variable3?

Are they the same even though Variable1 is a Button, Variable2 is a Label, and Variable3 is a TextBox?

+3


source to share


4 answers


Apart from Dredel's answer, you can also log into the console with the available properties and methods of the object using console.dir(document.getElementById('idhere'));

or their variants.



+3


source


you can do for(var a in obj)

and get a list of everything the object has in it. In your case for(a in Variable1)

will show all objects. Then you can look at them (in a loop) throughVariable1[a]



And they will be pretty much the same assuming they are part of the DOM, because DOM objects all inherit from the same display object, but no, they won't be identical as some HTML objects have unique properties that are not shared Worldwide. Get ready for a long list!

+2


source


MDN is a good recommendation. Start with Node and Element , from which almost every HTML element inherits.

Another good way to find out what DOM links are: HTML Level 2 IDL and JavaScript .

There are other definitions in the HTML5 standard .

+2


source


In modern browsers, you can use

Object.getOwnPropertyNames(variable1)

      

This will only return its own properties, not inherited ones. If you want all of them to use for (var property in obj) ...

.

Elements all inherit from the same objects, so they have basically the same properties; you will find differences such as .checked

, .multiple

etc.

0


source







All Articles