方法 | 介紹 | 示例 |
---|---|---|
css() | 獲取樣式屬性 | $(".test").css("color") |
css() | 設(shè)置樣式屬性 | $(".test").css("color","red") |
css() | 設(shè)置多個樣式屬性 | $(".test").css({'color':'red','background-color':'#555'}) |
height() | 獲取和設(shè)置元素實際高度不帶單位 | |
width() | 獲取和設(shè)置元素實際寬度不帶單位 |
offset()
獲取元素在當前視窗等相對偏移量 ,包含left和top兩個偏移量
$(".test").offset().left;
$(".test").offset().top;
*position()
獲取元素在當前視窗等相對偏移量 ,包含left和top兩個偏移量
$("li").position().left;
$("li").position().top;
scrollTop() scrollLeft()
獲取和設(shè)置元素滾動條距離頂端等距離
$(".test").scrollTop(200);
$(".test").scrollLeft();