<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="div1" style="font-size: 50px;">我是一个段落</div>
</body>
<script type="text/javascript">
<!--新增或修改属性-->
document.getElementById("div1").setAttribute("style","fontSize:20px;color:red");
// 获取属性值
var x= document.getElementById("div1").getAttribute("style");
console.log(x);
</script>
</html>