CSS - Jquery操作樣式

1 直接添加style

添加一個css屬性
$(".channel").css({ "position": "static" });
添加多個css屬性
$(".channel").css({ "position": "fixed", "width": "100%", "top": "0" });

2 添加刪除class

定義一個class
.channel-fixed {
  position: fixed;
  width: 100%;
  top: 0;
}
添加class
$(".channel").addClass("channel-fixed");
刪除class
$(".channel").removeClass("channel-fixed");
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章