📅  最后修改于: 2022-03-11 15:03:57.533000             🧑  作者: Mango
// Selecting an Element by id:
document.getElementById("elem-id");
// Selecting Elements by class:
document.getElementsByClassName("elem-class");
// Selecting Elements by tag name:
document.getElementsByTagName("div");
// Selecting Elements by name:
document.getElementsByName("elem-name");
/* This method is like a jQuery selector
( #elemId -> id, .elemClass -> class, h1 -> tag name) */
document.querySelector(".container"); // class
document.querySelector("#demo"); // id
document.querySelector("div"); // tag name