Monday, December 9, 2019

Module 4: Element Properties and Methods(getters and setters)

Getters and Setters

console.dir(element);
//will show you the object properties.

element.textContent
//get the text inside the element. This is the newer of the methods. It shows you also the hidden ones.

element.innerText
//Just the text inside without the hidden elements.

element.innerHTML
element.outerHTML
//gets the HTML inside and outside the element.

pizzaList.textContent = `${pizzaList.textContent} pizza🍕`;
//Include the text pizza. But it's slow. The alternative:

pizzaList.insertAdjacentText('beforeend', 'pizza');
//It inserts the text pizza before the end. It takes the place first:
beforebegin
afterbegin
beforeend
aftereend
Then the element you want to add.

Place to find all the different properties:
https://developer.mozilla.org/en-US/docs/Web/API/Element



No comments:

Post a Comment

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

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