Skip to main content

JavaScript Dot Operator List

JavaScript Dot Operator List

Quick Reference guide of dot operators:

.length
// counts the number of items in an array
.nodeName
// reference the name of the node, i.e. p for p tag, etc.
.parentNode
// references the parent on an element node
.childNodes
// references the elements of children. i.e. the parent can be a <ul> tag and the children would be the <li> tags. You reference them as you arrays, .childNodes[0] onwards.
.firstChild
// as above, but just gets the 1st child... same as .childNodes[0]
.lastChild
// as above, but gets the last child... same as childNodes[childNodes.length - 1]
.nextSibling
// if using the <ul><li> example, and you referenced the <li> tag, this will get the next <li> tag in the list.
.previousSibling
// as above but the other way round.
.getAttribute()
// returns the attribute in the brackets, i.e. myTitle = myVar.getAttribute("title");
.href
// you can just reference the attribute with the dot operator as you would an object. i.e. myTitle = myVar.href;
.setAttribute("attribute", "value")
// i.e. myVar.setAttribute("href", "/koko/");
.style
// followed by the CSS property, can change the CSS.
.style.color
// i.e. myElement.style.color = "#FF0000";
.className
// myElement.className = "my-css-class";
.createElement()
// creating new elements to add to the html, i.e. document.createElement("span");
.createTextNode()
// creating new content text to add to an element, i.e. document.createTextNode("Text goes here");
.appendChild()
// adding a child element to an existing node, i.e. tip.appendChild(tipText);
.nextSibling
.nodeValue
.removeChild()
// i.e. removeChild(tip)
Main Category
  • Javascript
  •  
 
Jon Moore

Search form

Jon Moore

Tips 'n' Snips

 
  • Home
  • General
  • Drupal
    • Drupal 6
    • Drupal 7
    • Module Building
  • HTML & CSS
  • Javascript
  • jQuery
  • PHP
    • CodeIgniter
    • Handy Functions
    • MySQL
  • WordPress
  • About

BBC Technology News

  • Heathrow: Man charged with flying drone near airport
  • Girl Scouts of America offer badge in cybersecurity
  • Rise in nude photos sent to phones on public transport
  • Are these the faces of the future?
  • Zimbabwe blocks Facebook, WhatsApp and Twitter amid crackdown
More

Sitepoint

  • How to Build Your First Static Site with Gatsby
  • Customer Journey Maps: A Day in the Life of a Customer
  • How to Take JavaScript Beyond the Web in 2019
  • Check out the 6 Best Productivity Apps for Designers
  • 7 Awesome Wireframing Tools You Should Be Using
More

Heart Internet

  • Did he really just say that? How to deal with an obnoxious client
  • Product management for designers
  • Talking to your clients about WordPress plugin security
  • The developer’s guide to native web animation
  • Are you seeing clearly? The role of visual thinking in creative work
More
 

Backend Coders

  • PHP
  • Handy PHP Functions
  • PHP MySQL

Frontend Coders

  • HTML & CSS
  • jQuery
  • Javascript

CMS/CMF Systems

  • Drupal
  • Drupal 6 Specific
  • Drupal 7 Specific
  • Drupal Module Building
  • WordPress

About

  • Home
  • About
 

© Jon Moore 2019

All stock images are from www.istockphoto.com