jQuery操作css样式的方法

<html>

<head>
<title></title>
</head>
    <style>
        
    </style>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
        
        $(function(){
            //逐一设置样式
            $('div').css("width","100px")
            $('div').css("height","100px")
            $('div').css("background","red")
            //链式设置
            $('div').css("width","100px").css("height","100px").css("background","blue")
            //批量设置(推荐使用)
            $('div').css({
                width:"100px",
                height:"100px",
                background:"red"
            })
        })
        
    </script>
    
<body>
    <div> </div>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/superCwen/p/9911035.html