;(function(a){a.fn.extend({actual:function(b,l){if(!this[b]){throw'$.actual => The jQuery method "'+b+'" you called does not exist';}var f={absolute:false,clone:false,includeMargin:false};var i=a.extend(f,l);var e=this.eq(0);var h,j;if(i.clone===true){h=function(){var m="position: absolute !important; top: -1000 !important; ";e=e.clone().attr("style",m).appendTo("body");};j=function(){e.remove();};}else{var g=[];var d="";var c;h=function(){c=e.parents().andSelf().filter(":hidden");d+="visibility: hidden !important; display: block !important; ";if(i.absolute===true){d+="position: absolute !important; ";}c.each(function(){var m=a(this);g.push(m.attr("style"));m.attr("style",d);});};j=function(){c.each(function(m){var o=a(this);var n=g[m];if(n===undefined){o.removeAttr("style");}else{o.attr("style",n);}});};}h(); var k=/(outer)/g.test(b)?e[b](i.includeMargin):e[b]();j();return k;}});})(jQuery);
1 回答
温温酱
TA贡献1752条经验 获得超4个赞
大概看了一遍封装一个脚本 获取一些元素,当元素怎样时增加一些定位和隐藏!
;( function (a){ //封装jq写法 a.fn.extend({ //定义a脚本 actual: function (b,l){ //定义a.actual 带变量b,1 if (! this [b]){ //如果不存在这个b throw '$.actual => The jQuery method "' +b+ '" you called does not exist' ; } //好像是抛出异常吧 var f={ absolute: false ,clone: false ,includeMargin: false }; //定义f var i=a.extend(f,l); var e= this .eq(0); var h,j; if (i.clone=== true ){ h= function (){ var m= "position: absolute !important; top: -1000 !important; " ; e=e.clone().attr( "style" ,m).appendTo( "body" );}; j= function (){e.remove(); }; } else { var g=[]; var d= "" ; var c; h= function (){ c=e.parents().andSelf().filter( ":hidden" ); d+= "visibility: hidden !important; display: block !important; " ; if (i.absolute=== true ){ d+= "position: absolute !important; " ; }c.each( function (){ var m=a( this ); g.push(m.attr( "style" )); m.attr( "style" ,d); }); };j= function (){ c.each( function (m){ var o=a( this ); var n=g[m]; if (n===undefined){ o.removeAttr( "style" ); } else { o.attr( "style" ,n); } });};}h(); var k=/(outer)/g.test(b)?e[b](i.includeMargin):e[b]();j(); return k;}});})(jQuery); |
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报
0/150
提交
取消