代码示例:(标识:jsck_element_classlist_item)
<!DOCTYPE html>
<html>
<style>
.myStyle {
  background-color: coral;
  padding: 16px;
}
.anotherClass {
  text-align: center;
  font-size: 25px;
}
.thirdClass {
  text-transform: uppercase;
}
</style>

<body>
<h1>DOMToken 对象</h1>

<h2>item() 方法</h2>

<div id="myDIV" class="myStyle anotherClass thirdClass">
<p>I am a myDIV.</p>
</div>

<p>“myDIV”中第一个类的类名是:</p>

<p id="demo"></p>

<script>
let className = document.getElementById("myDIV").classList.item(0);
document.getElementById("demo").innerHTML = className;
</script>

</body>
</html>
运行结果: