<!DOCTYPE html>
<html>
<body class='xx'>
<p id="demo"></p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=document.body.class;
}
</script>
</body>
</html>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你能不能看一看API
document.body.classNamedocument.body.classList哪里有class属性