课程: JavaScript Essential Training

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Access elements with querySelector methods

Access elements with querySelector methods - JavaScript教程

课程: JavaScript Essential Training

Access elements with querySelector methods

- [Instructor] Let's take a look at how to access elements in the DOM using JavaScript. In the exercise files for this movie, I've updated our examples so we have some actual content to work with. I've added some basic HTML and a style sheet in index.html and I've also expanded the HTML output in the template literal a little bit to make it possible to style it. I've added some classes. I've wrapped spans around the values, and I've also added an image at the top here. Looking at the project site in the browser you'll see, it looks quite different but there's nothing new here in terms of JavaScript. I've just expanded on what we've covered so far in the course. All right, anytime you want to do something in the DOM you start by finding the element or elements you want to work with. For this, we have two methods: query selector and query selector all. And they both apply to the document object. These methods use…

内容