设置css样式/读取css值
css()

1. 得到第一个p标签的颜色
2. 设置所有p标签的文本颜色为red
3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)

        //1. 得到第一个p标签的颜色
    console.log($("p:first").css("color"))
    // 2. 设置所有p标签的文本颜色为red
    $("p").css("color","red")
    // 3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)
    $("p:nth-child(2)").css({
        "color":"#ff0011",
        "background":"blue",
        "width":"300px",
        "height":"30px",
        
        })

 

相关文章:

  • 2021-08-04
  • 2021-11-26
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-12-26
猜你喜欢
  • 2021-07-04
  • 2021-07-08
  • 2022-12-23
  • 2021-10-02
  • 2022-02-11
  • 2022-01-06
  • 2021-06-08
相关资源
相似解决方案