`
mimang2007110
  • 浏览: 232390 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

JQuery CSS 方法说明

阅读更多

css( name ) 访问第一个匹配元素的样式属性。 css( properties ) 把一个”名/值对”对象设置为所有匹配元素的样式属性。 $(”p”).hover(function () { $(this).css({ backgroundColor:”yellow”, fontWeight:”bolder” }); }, function () { var cssObj = { backgroundColor: “#ddd”, fontWeight: “”, color: “rgb(0,40,244)” } $(this).css(cssObj); }); css( name, value ) 在所有匹配的元素中,设置一个样式属性的值。 offset( ) 取得匹配的第一个元素相对于当前可视窗口的位置。返回的对象有2个属性, top和left,属性值为整数。这个函数只能用于可见元素。 var p = $(”p:last”); var offset = p.offset(); p.html( “left: ” + offset.left + “, top: ” + offset.top ); width( ) 取得当前第一匹配的元素的宽度值, width( val ) 为每个匹配的元素设置指定的宽度值。 height( ) 取得当前第一匹配的元素的高度值, height( val ) 为每个匹配的元素设置指定的高度值。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics