<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<div id='box' class="a b c"></div>
</body>
</html>
<script>
var dom = document.querySelector('#box');
console.log(dom.getAttribute('class'))
console.log(dom.className)
</script>
js怎样获取元素有哪些类 class 原生js获取元素的类名
最新推荐文章于 2024-05-07 17:38:03 发布