2022-03-29_CSS操作

2022-03-28  本文已影响0人  微笑碧落

1.添加、删除、切换元素的class属性

addClass() - 向被选元素添加一个或多个类
removeClass() - 从被选元素删除一个或多个类
toggleClass() - 对被选元素进行添加/删除类的切换操作
hasClass()
$("div").addClass("important");

2.设置、返回css属性值

css("propertyname"); 返回css属性值
css("propertyname","value");设置css属性值
$("p").css("background-color","yellow");
$("p").css(
  {
    "background-color":"yellow",
    "font-size":"200%"
  }
);

3.尺寸

width()
height()
innerWidth()
innerHeight()
outerWidth()
outerHeight()
$("#div1").outerWidth()
jquery尺寸.gif

4.引用

1.jquery教程

上一篇 下一篇

猜你喜欢

热点阅读