zoukankan      html  css  js  c++  java
  • 单独设置css的class属性

    <!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>单独设置cssclass属性</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>
  • 相关阅读:
    奇迹银桥「1」
    20190729-“退役”专场
    20190727-只是睡着了
    $mathcal{Miemeng}$的病态码风计划
    20190725-Silly
    作业-[luogu4396][AHOI2013]-莫队
    数学网学笔记
    20190722-Moni和Boly的故事
    数学学习笔记
    20190719-FirstZero
  • 原文地址:https://www.cnblogs.com/masita/p/5368638.html
Copyright © 2011-2022 走看看