Free Web Development Online Tutorials, Learn to Code
javascript dom get element by class name, javascript for dom manipulation, javascript with dom examples

JavaScript DOM Manipulation

Javascript DOM

JavaScript DOM Examples

What is DOM? DOM is (Document Object Model) an object structure of document, where JavaScript can access each object either by their name, id or css-class .

In JavaScript we can access object by some methods like getElementById, getElementsByName, getElementsByClassName etc.

After accessing the object we can set/reset some properties (like value, innerHTML, innerText ) of that object

Here is an Example, we simply want to change the label of the button below once the button is clicked.

This is how we can access the button DOM using javascript, then write a function and call on button click event

document.getElementById("btnUpdate").value = "Yes, You have clicked";

Now let's look at another example of changing the innerHTML of a DIV using JavaScript DOM

Learning Javascript DOM is Fun!

Click => , Below is the code.

document.getElementById("dvDomTest").innerHTML = "Oh Yes, Learning JavaScript DOM, will use in my Project";

To write anything in document use document.write(string)

document.write("Javascript DOM easy to work wiith");