Categories
JavaScript Selecting

JavaScript for optimizers #26: How to select an element type?

Example

Select an element type:

let getParagraph = document.querySelector("p"); 
console.log(getParagraph);

Try it out for yourself by going to the testing page and running the code in the browser console.

Categories
JavaScript Selecting

JavaScript for optimizers #25: How to select an element with multiple classes?

Example

Select an element with multiple classes:

let testImage = document.querySelector(".classOne.classTwo");
console.log(testImage);

Try it out for yourself by going to the testing page and running the code in the browser console.

Categories
JavaScript Selecting

JavaScript for optimizers #24: How to select elements with ids?

Example

Select an element with an id:

let testImage = document.querySelector("#imageElement");
console.log(testImage);

Try it out for yourself by going to the testing page and running the code in the browser console.

Categories
JavaScript Selecting

JavaScript for optimizers #23: How to select an element with a class?

Example

Select an element with a class:

let testImage = document.querySelector(".wp-image-1596");
console.log(testImage);

Try it out for yourself by going to the testing page and running the code in the browser console.

Categories
JavaScript Selecting

JavaScript for optimizers #1: Hiding class elements

Our hypothetical case for this chapter is about hiding class elements.

Our client’s research showed that websites should avoid using meaningless design elements because that burdens cognitive load.

Numerous surveys showed that users on their website find the design very confusing.