jQuery技术

jquery源码学习笔记二

字号+ 作者:H5之家 来源:H5之家 2015-11-22 10:22 我要评论( )

jquery源码学习笔记二——CSS样式相关部分 网站前台技术

opacity: { get: ret = curCSS( elem, "opacity");returnret === "" ? "1": ret; } elem.style.opacity; } } } } }); ( !jQuery.support.opacity ) {//如果不支持style.opacity,关于support下文有讲到,暂时从字面上理解即可jQuery.cssHooks.opacity ={ get: ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?computed ? "1" : "";//不存在:未设置opacity,视为全部透明,即1}, set: style =elem.style, currentStyle =elem.currentStyle, opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",//为IE、非IE保持一致,需要乘以100filter = currentStyle && currentStyle.filter || style.filter || ""; style.zoom = 1;( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "") { style.removeAttribute( "filter"); ( currentStyle && !currentStyle.filter ) {return; } } //otherwise, set new filter valuesstyle.filter = ralpha.test( filter ) ?filter.replace( ralpha, opacity ) : filter + " " +opacity; } }; } jQuery(( !jQuery.support.reliableMarginRight ) { jQuery.cssHooks.marginRight ={ get: jQuery.swap( elem, { "display": "inline-block" }, curCSS( elem, "margin-right"); } elem.style.marginRight; } }); } }; } }); jQuery.each({ margin: "", padding: "", border: "Width"}, function( prefix, suffix ) { jQuery.cssHooks[ prefix + suffix ] ={ expand: i, //assumes a single number if not a stringparts = typeofvalue === "string" ? value.split(" ") : [ value ], expanded ={}; for( i = 0; i < 4; i++) { expanded[ prefix + cssExpand[ i ] + suffix ] =parts[ i ] || parts[ i - 2 ] || parts[ 0]; } returnexpanded; } }; }); getWidthOrHeight( elem, name, extra ) { val = name === "width" ?elem.offsetWidth : elem.offsetHeight, i = name === "width" ? 1 : 0, len = 4; ( extra !== "border"( !extra ) { val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0; }if( extra === "margin") { val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0; } else{ val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; } } } returnval + "px"; } ( val < 0 || val == null) {//会有小于0的情况吗???val =elem.style[ name ]; } ( rnumnonpx.test(val) ) {val; } //Normalize "", auto, and prepare for extraval = parseFloat( val ) || 0; ( ; i < len; i += 2) { val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;if( extra !== "padding") { val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; }if( extra === "margin") { val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0; } } } returnval + "px"; }

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • jQuery入门教程之二

    jQuery入门教程之二

    2015-11-09 18:14

网友点评
(