div.style.cssText = “color:white; background-color:green;”;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<style>
.test-1 {
background-color: red;
color: green;
padding: 50px;
}
</style>
<body>
<div class="test-1">
啦啦啦啦啦啦啦啦啦
</div>
<script>
const div = document.querySelector('.test-1');
div.style.cssText = `
color:white;
background-color:green;
padding:100px;
box-shadow:0 0 80px #333;
`;
</script>
</body>
</html>
来源:CSDN
作者:全易
链接:https://blog.csdn.net/qq_42618566/article/details/104136782