<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>单独设置css的class属性</title>
<style>
.error{
width: 100px;
height: 100px;
color: red !important;
}
</style>
</head>
<body>
<div class="error" id="div1" style="background:black;color:blue;">hello world</div>
<script>
var odiv = document.getElementById('div1');
//设置单个属性
// odiv.style.setProperty('color', 'green', 'important');
//设置整个style属性
// odiv.setAttribute('style', 'color:green !important');
//http://stackoverflow.com/questions/19828515/how-to-override-css-containing-important-using-jquery
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>单独设置css的class属性</title>
<style>
.error{
width:100px;
height:100px;
color:red !important;
}
</style>
</head>
<body>
<div class="error" id="div1" style="background:black;color:blue;">helloworld</div>
<script>
var odiv = document.getElementById('div1');
//设置单个属性
// odiv.style.setProperty('color', 'green', 'important');
//设置整个style属性
// odiv.setAttribute('style', 'color:green !important');
//http://stackoverflow.com/questions/19828515/how-to-override-css-containing-important-using-jquery
</script>
</body>
</html>