歡迎您光臨本站 註冊首頁

· jquery css雜誌閱讀

jQuery CSS 函式

admin @ 2020-04-18 reply:0

jQuery CSS 操作

jQuery 擁有三種用於 CSS 操作的重要函式:

  • $(selector).css(name,value)

  • $(selector).css({properties})

  • $(selector).css(name)

CSS 操作例項

函式 css(name,value) 為所有匹配元素的給定 CSS 屬性設定值:

例項

$(selector).css(name,value)
$("p").css("background-color","red");

親自試一試

函式 css({properties}) 同時為所有匹配元素的一系列 CSS 屬性設定值:

例項

$(selector).css({properties})
$("p").css({"background-color":"red","font-size":"200%"});

親自試一試

函式 css(name) 返回指定的 CSS 屬性的值:

例項

$(selector).css(name)
$(this).css("background-color");

親自試一試

jQuery Size 操作

jQuery 擁有兩種用於尺寸操作的重要函式:

  • $(selector).height(value)

  • $(selector).width(value)

Size 操作例項

函式 height(value) 設定所有匹配元素的高度:

例項

$(selector).height(value)
$("#id100").height("200px");

親自試一試

函式 width(value) 設定所有匹配元素的寬度:

例項

$(selector).width(value)
$("#id200").width("300px");

親自試一試

jQuery CSS 函式 - 來自本頁

CSS 屬性描述
$(selector).css(name,value)為匹配元素設定樣式屬性的值
$(selector).css({properties})為匹配元素設定多個樣式屬性
$(selector).css(name)獲得第一個匹配元素的樣式屬性值
$(selector).height(value)設定匹配元素的高度
$(selector).width(value)設定匹配元素的寬度



[admin via ] jQuery CSS 函式已經有422次圍觀

http://coctec.com/magazine/show-post-item-62.html