Table of Contents
Back Button
Back to Chapter
Control Statements
No items found.
Function & Events
No items found.
Array and its Types
No items found.
OOP : Object Oriented Programming
No items found.
Javascript Standards
No items found.
HTML DOM
No items found.
Javascript : Advanced 1
No items found.
Javascript : Advanced 2
No items found.
Additional JavaScript
No items found.

Methods & Properties

Methods

In DOM, If you want to access any element in an HTML page, you have to start with accessing the document object and in Addition with Methods.

Example : if we want to select the paragraph with id⇒myParagraph then you need to select the document then you need to use the method getElementById  i.e. document.getElementById("myParagraph");

So, There are many methods to select the Element of the Document.

Methods List

There are Some Other document Methods that are used to select All The Elements of Same kind.

Additional Methods

Example :

document.write("Hello World"); // This will write the Text into New Document

Properties

Now, As you have learnt to select the Element, you should also know about the Properties because without properties you cannot get or change the content of the selected Element.

Here, I am Using getElementById method, you can also use other method to Select the element.

Example 1:

Hello Guys!!! This is my First Paragraph

// Output // Hello Guys!!! This is my First Paragraph

Here,

We have used document.getElementById(id).innerHTML Property

It will select the paragraph element by its id and Outputs the Text inside the Element by innerHTML property.

Example 2:

Here,

We have used document.getElementById(id).attribute = New Text Property and src as Attribute.

It will select the img element by its id  i.e. myImage and changes the src attribute of the img Element.

Ask queries
Contact Us on Whatsapp
Hi, How Can We Help You?