css多个属性怎么写,.css多个属性读取写法?

本文详细解析了jQuery中设置元素宽度和高度的方法。通过源码分析,解释了如何使用jQuery来获取或设置DOM元素的width和height属性,并讨论了不同情况下这些属性的行为差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

object.css('width','height') 这个是设置的格式啊。当前的意思是object的width的值被设置成了height。但是你看它返回的应该是一个函数,看样子像原码。具体没看了。  widht:function ( margin, value ){

var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),

extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );

return jQuery.access( this, function( elem, type, value ) {

var doc;

if ( jQuery.isWindow( elem ) ) {

// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there

// isn't a whole lot we can do. See pull request at this URL for discussion:

// https://github.com/jquery/jquery/pull/764

return elem.document.documentElement[ "client" + name ];

}

// Get document width or height

if ( elem.nodeType === 9 ) {

doc = elem.documentElement;

// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest

// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.

return Math.max(

elem.body[ "scroll" + name ], doc[ "scroll" + name ],

elem.body[ "offset" + name ], doc[ "offset" + name ],

doc[ "client" + name ]

);

}

return value === undefined ?

// Get width or height on the element, requesting but not forcing parseFloat

jQuery.css( elem, type, extra ) :

// Set width or height on the element

jQuery.style( elem, type, value, extra );

}, type, chainable ? margin : undefined, chainable, null );

} height:function ( margin, value ) {

var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),

extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );

return jQuery.access( this, function( elem, type, value ) {

var doc;

if ( jQuery.isWindow( elem ) ) {

// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there

// isn't a whole lot we can do. See pull request at this URL for discussion:

// https://github.com/jquery/jquery/pull/764

return elem.document.documentElement[ "client" + name ];

}

// Get document width or height

if ( elem.nodeType === 9 ) {

doc = elem.documentElement;

// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest

// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.

return Math.max(

elem.body[ "scroll" + name ], doc[ "scroll" + name ],

elem.body[ "offset" + name ], doc[ "offset" + name ],

doc[ "client" + name ]

);

}

return value === undefined ?

// Get width or height on the element, requesting but not forcing parseFloat

jQuery.css( elem, type, extra ) :

// Set width or height on the element

jQuery.style( elem, type, value, extra );

}, type, chainable ? margin : undefined, chainable, null );

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值