Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Change Your Web Page with JavaScript Document Object Model Methods

Part of the JavaScript & AJAX For Dummies Cheat Sheet

The Document Object Model methods shown in the following table offer you a great way to access and modify your Web pages through your JavaScript code.

Element Description
myElement = document.getElementById("name"); Gets an element from the page with the specified ID and copies a reference to that element to the variable myElement.
myElement.innerHTML = "value" Changes the value of the element to "value".
document.onkeydown = keyListener When a key is pressed, a function called keyListener is automatically activated.
document.onmousemove = mouseListener When the mouse is moved, a function called mouseListener is automatically activated.
setInterval(function, ms); Runs function each ms milliseconds.
myArray = document.getElementsByName("name") Returns an array of objects with the current name (frequently used with radio buttons).
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!