javaScript native get DOM elements

JS native acquired DOM element method (8 types)

  • Acquiring the ID (the getElementById)
  • Get (getElementsByName) by the name attribute
  • Get (getEleByTagName) by the tag name
  • Get (getEmentsByClassName) by Class class name
  • Obtaining an element (querySelector) by the selector
  • Obtaining a set of elements (querySelectAll) by the selector
  • Methods (document.documentElement) Gets the HTML
  • The method of obtaining body (document.body): dedicated to acquiring the label body used

Get the syntax elements introduced by the selectors:

//通过选择器获取一个元素
document.querySelector(".animated");
//通过选择器获取一组元素
document.querySelectorAll(".animated");

 

Published 13 original articles · won praise 4 · Views 497

Guess you like

Origin blog.csdn.net/qq_44384173/article/details/103987782