querySelector
querySelector is a method in JavaScript that allows you to select an HTML element from the DOM (Document Object Model) using a CSS selector. It returns the first matching element found in the document. Here's an example of using querySelector to select an element with a specific class:
const element = document.querySelector('.my-class');
This would select the first element in the document that has a class of "my-class". You can also use querySelector to select elements by tag name, ID, or any other CSS selector.
原文地址: https://www.cveoy.top/t/topic/6Py 著作权归作者所有。请勿转载和采集!