在jquery中的css方法中使用多个属性

时间:2014-07-30 16:27:16

标签: jquery

如何在jquery的css方法中使用多个属性?

$(document).ready(function(e){
        $("#dv1").click(function(){
            $(this).css("height","200px")
            $(this).css("backgroundColor","red")
        })
    })

1 个答案:

答案 0 :(得分:2)

您可以以对象形式指定所有CSS属性:

$(document).ready(function(e){
    $("#dv1").click(function(){
        $(this).css({
            height: "200px",
            backgroundColor: "red"
        });
    });
});
相关问题