Jump to content

getElementById Methods


shermanDye

Recommended Posts

So I am learning JavaScript, and I come across this (which is one of the first things I learned about JS from your website, thank you). The first "method", if you call it that, which you show is the .innerHTML method to change the interior of an HTML element, given a named id. I have since learned other methods to be used with it, such as .value and .style. But I have never seen a comprehensive list of all the methods that can be used with this command. Either I'm not looking in the right place (which is entirely possible), or it's just not there. Since this is supposed to be a comprehensive website for all things related to web development, I think this would be a great addition to an already great website.

Edited by shermanDye
Link to comment
Share on other sites

Those aren't necessarily methods but properties actually. They are properties of that particular element. An HTML element is actually an object - an object has properties and methods(functions). .innerHTML, value, etc are properties for example of a particular element that you can reference to by using document.getElementById('myElement' ); getElementById() is actually a method for the 'document' object.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...