Introduction to javaScript DOM 102

The javascript DOM API have a lot of interesting features, and can be used to do cool stuffs like appending a new paragraph, creating a pop-up message, resizing web content to fit the display window e.t.c.

you can manipulate anything on the page using javascript Dom Api

lets take a look at some of the things we can do with the Dom Api.

we can show all the different properties and methods attached to the document object by executing this code:

 console.dir(document);

You can print out the domain you are working on

console.log(document.domain);

You can access the URL

console.log(document.URL);

Get title of the page

console.log(document.title);

We can change the title of the page

document.title = 'new title';

Get the Doctype

console.log(document.doctype);

You can get the head and body tag

console.log(document.head);

this will print out everything in the head tag to the console. same thing with the body tag.

console.log(document.all);

this will give you an array of everything in the html element.

A lot can be done using the javascript Dom Api. this is just a tiny piece of what you can do with the Dom Api.

the code for this post is available on github.

Subscribe to my Newsletter

Don't miss out on new articles from me. Get notified when a new article is published.