Methods to target DOM Elements
Selectors are one or more comma separated CSS selectors
-
/* Get the FIRST element matching specified selector(s) */ - document.querySelector ('.main-nav a');
-
/* Get ALL elements matching specified selector(s) as an array */ - document.querySelectorALL ('some.post-content p');
Methods to change DOM Elements
Selectors are one or more comma separated CSS selectors
-
/* Assign targeted element with desired change */ - document.querySelector ('.main-title').innerHTML = "The new title now reads THIS";
-
/* Get ALL elements matching specified selector(s) as a node list */ - document.querySelectorALL ('some.post-content p');