【问题标题】:use more than one property in css method in jquery [duplicate]在jquery的css方法中使用多个属性[重复]
【发布时间】:2023-03-17 11:21:02
【问题描述】:

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

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

【问题讨论】:

    标签: jquery


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2013-10-27
      • 2013-06-23
      • 2020-11-01
      • 1970-01-01
      • 2015-11-26
      • 2020-02-03
      • 2020-06-16
      • 2014-08-27
      • 1970-01-01
      相关资源
      最近更新 更多