课程: JavaScript Essential Training
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Modifying element classes
- [Instructor] A common task in JavaScript is to modify the classes of an element in some way. This is a simple way of changing the appearance or behavior of an element without having to inject CSS into the HTML itself. Instead, we just add a class or remove a class to make something happen. Examples of this include hiding and showing a panel, or highlighting a button when something else has happened, like now that you've done step one, click here to continue, et cetera. Class manipulation is common enough, that we have two specialized properties for it. The first one and the oldest one is class name, and it's available for all elements in the dom. Class name holds a string, listing out all the classes appended to an element. We can see it if we go to our exercise files and the console. So the H1 here has the class backpack name, and we can call up the H1 in JavaScript and get just that output. So document, query…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
DOM: The Document Object Model4 分钟 7 秒
-
(已锁定)
Access elements with querySelector methods6 分钟 6 秒
-
(已锁定)
Access elements using older methods3 分钟 45 秒
-
(已锁定)
Practice: Find an element1 分钟 29 秒
-
(已锁定)
Modifying element classes4 分钟 53 秒
-
(已锁定)
Attributes4 分钟 13 秒
-
(已锁定)
Inline style3 分钟 52 秒
-
(已锁定)
Practice: Modify classes and attributes, and styles1 分钟 36 秒
-
(已锁定)
Add DOM elements5 分钟 25 秒
-
(已锁定)
Challenge intro: Create elements1 分钟 17 秒
-
(已锁定)
Solution: Create elements3 分钟 35 秒
-
-
-
-
-
-
-