📜  如果类列表包含 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:30.640000             🧑  作者: Mango

代码示例4
let span = document.querySelector("span");
let classes = span.classList;
let result = classes.contains("d");
if (result) {
  span.textContent = "The classList contains 'c'";
} else {
   span.textContent = "The classList does not contain 'c'";
}