将检索

<a class="class-name">Any</a>
<b class="class-name">tag</b>
<div class="class-name an-extra-class">with that class.</div>

如果没有现有元素包含给定的类,则将返回一个空集合。


示例

<p class="my-class">I will be matched</p>
<p class="my-class another-class">So will I</p>
<p class="something-else">I won't</p>
var myClassElements = document.getElementByClassName('my-class');
console.log(myClassElements.length); // 2
var nonExistentClassElements = document.getElementByClassName('nope');
console.log(nonExistentClassElements.length); // 0

热门推荐

1 要红包拜年祝福语简短
2 l离别祝福语大全简短
3 新年祝福语简短叔叔阿姨
4 谷雨祝福语简短文字
5 长辈祝福语简短小故事
6 公司年会祝福语简短感谢
7 老公生日祝福语简短情话
8 女儿升大班祝福语简短
9 送企业祝福语简短的
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短