动态修改a标签的css样式

<!DOCTYPE html>

<html>
 
    <head>
        问<meta charset="UTF-8">
        <title></title>
        <style type="text/css">
        a{
            width: 50px;
            height: 50px;
            background: red;
        }
 
        </style>
    </head>
 
    <body>
        <script>
            var number;
 
            function clicke() {
            var a = document.getElementById("mya");
                    a.style.cssText +="; display:block;width: 100%;height:200px;background: yellow;";
            }
        </script>
        <a id="mya" href="#" onclick="clicke()">点击我答</a>
    </body>
 
</html>
$("#mya").addClass("on");
 
posted @ 2020-04-13 21:53  .net&new  阅读(1146)  评论(0编辑  收藏  举报