Monday, December 9, 2019

Module 4: Selecting Elements on the Page or DOM

const p = document.querySelector('p');
// Create a constant that will get the first 'p' element on the page. Works like CSS selector. #div p

document.addEventListener('DOMContentLoaded', function);
//make it wait until the DOMContent is loaded to start the function.

A NodeList is not an Array. It doesn't have the methods.

const p = document.querySelectorAll('p');
//get or select all the p elements on the page.


No comments:

Post a Comment

Arrays 4 : Callback Methods find() filter() some() every() sort()

  /* Callback Methods */ // const util = { // findBurgRating: function(singleFeedback) { // return singleFeedback.comment....