Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为JavaScript编写类?_Javascript_Html - Fatal编程技术网

如何为JavaScript编写类?

如何为JavaScript编写类?,javascript,html,Javascript,Html,这是我的班级: .yt-card.yt-uix-expander .yt-uix-button-expander, .yt-card .yt-uix-expander .yt-uix-button-expander 有没有办法把它写得漂亮点: document.getElementsByClassName("class"); 你说的“写得漂亮”是什么意思?这并不是一个类(甚至不是很接近)将类更改为一个单词lol,而且代码中有多个类不仅仅是多个类,更糟糕的是-它是一个多部分选择器,其中每个部分

这是我的班级:

.yt-card.yt-uix-expander .yt-uix-button-expander, .yt-card .yt-uix-expander .yt-uix-button-expander
有没有办法把它写得漂亮点:

document.getElementsByClassName("class");

你说的“写得漂亮”是什么意思?这并不是一个类(甚至不是很接近)将类更改为一个单词lol,而且代码中有多个类不仅仅是多个类,更糟糕的是-它是一个多部分选择器,其中每个部分用多个类或多个元素命名元素。这个问题毫无意义。我知道,所以我在问。以“…”号填列;我不能有点,但是。yt卡。yt uix扩展器。。。我能用它做什么?或者更简单。如何将:.yt-card.yt-uix-expander.yt-uix按钮扩展器放入document.getElementsByClassName?
var matches = document.querySelectorAll(
    ".yt-card.yt-uix-expander .yt-uix-button-expander, .yt-card .yt-uix-expander .yt-uix-button-expander");