Selecting all page elements?

0

I was thinking about Grid-CSS , I read in some sites about frameworks that exist for him, and that in general are very bad, because they limit the capacity of the technology, so I thought, framework , where javascript checks all elements one by one, and if they have data-attributes referring to the use of grid , apply certain rules to those elements according to the values added by the developer (in In general, classes determine the properties used, but this would limit the number of columns, lines, where everything starts or ends, and so on, if it only assigns the values to those properties, the only limit would be placed by the developer himself )? (ex: <span data-grid-column-spacing="2/6">...</span> ).

For this, I thought, creating separate functions that select data-attributes according to what is used is a possibility, but I thought, why not select all the elements at once, and then check and add the styles in each?

  • So, my question is, how can I select all the elements at once, regardless of the name of the element, or where on the page it is?
asked by anonymous 29.11.2017 / 17:05

1 answer

1

To select all elements of an HTML page, use the querySelectorAll, via CSS selectors or getElementsByTagName, using the * symbol to select all nodes. See the implementations below:

getElementsByTagName

var elementos = document.getElementsByTagName('*');

querySelectorAll

var elementos = document.querySelectorAll('*');
    
29.11.2017 / 17:07