I appreciate the clarity of this trick that Mikael Ainalem posted over on Reddit:
It’s a one-liner that toggles the class on the
so you can mock up different states and toggle between them on click.<body onclick="this.classList.toggle("active");">
Could be on any element as well!
This can be a big thing. See “The Power of Changing Classes” as a case in point. Even if you aren’t much of a JavaScript person, classList is perhaps the one API you should know.
以上是车身切换的详细内容。更多信息请关注PHP中文网其他相关文章!