- Find a element by id. Return a list of elements.
document.getElementById(id)
- Find a element by name. Return a list of elements.
document.getElementsByTagName(name)
- Find a element by class. Return a list of elements.
document.getElementsByClassName(name)
- Insert a element in the HTML document.
document.createElement(element)
- Insert a element in the HTML document.
document.appendChild(element)
- Insert a text for a element.
document.createTextNode("text")
- Insert a element before another one
element.insertBefore(element,elementChild)
- Remove a element from a HTML document.
document.removeChild(element)
- Replace a element from a HTML document.
document.replaceChild(element)
- Get a value from a element.
- Get a value from a the first child element.
element.firstChild.nodeValue
- Get a value from a child element in position 0.
element.childNodes[0].nodeValue
- Get all from HTML document.
document.documentElement.innerHTML
- Get all from body element.
- Get all cookies. Return a list with key and value.
- Get window's width. Not include toolbar and scrollbar. Return in pixels.
window.innerWidth
document.documentElement.clientWidth
document.body.clientWidth
- Get window's height. Not include toolbar and scrollbar. Return in pixels.
window.innerHeight
document.documentElement.clientHeight
document.body.clientHeight
- Get screen's width. Return in pixels.
screen.width
screen.availWidth
- Get screen's height. Return in pixels.
screen.height
screen.availHeight
- Return the number of bits used to display a color on screen.
- Return the deep of pixels on the screen.
- Return URL from the current window.
- Return the host name from the current window.
- Return the path name from the current window.
- Return the protocol web (e.g., http, https) used by the current page.
- Return the browser's name (e.g., IE11, Chrome, Firefox, and Safari 'Netscape').
- Return the browser's codename (e.g., IE11, Chrome, Firefox, and Safari 'Mozilla').
- Return the SO used to run the current browser (e.g., Linux, Windows).
- Return the engine's name used on the browser.
- Return the language set on the browser (e.g., pt-br, en-us).
- Replace a content's value from an element.
element.innerHTML = new html content
- Replace a content's value from an element specified by id.
document.getElementById("id").innerHTML = "text"
- Replace a attribute's value from an element.
element.attribute = new value
- Replace a attribute's value from an element.
element.setAttribute(attribute, value)
element.style.property = new style
- Replace an attribute's value from an element specified by id.
document.getElementById("id")."any attribute" = "text"
- Replace the HTML document.
- Close the current window.
- Resize the current window.
window.location.assign(URL)
- Display a onformation on browser's console.
- Trigger a function after a specified time.
window.setTimeout(function, milliseconds)
- Trigger a function over and over in a specified interval.
window.setInterval(function, milliseconds)
- Trigger a function by a click event.
<script>
function myFunction()
{
document.getElementById("id").innerHTML = "text";
}
</script>
<tag onclick="myFunction()"> </tag>
- Trigger a function to replace the HTML document by a click event.
<tag onclick="document.write("text")">text</tag>
- Trigger a function to replace a content's value from an element by a click event.
<tag onclick="this.innerHTML="text"">text</tag>
- Assign an event to a element through addEventListener().
<script>
element.addEventListener("click", displayDate);
function displayDate()
{
document.getElementById("demo").innerHTML = Date();
}
</script>