當前位置:編程學習大全網 - 網站源碼 - jquery插件的源代碼分析

jquery插件的源代碼分析

1.將需要多次使用的元素保存為變量,避免多次遍歷,優化性能。

2.使用jquery鏈操作。

(功能?($)?{

$.fn.Couplet?=?功能(選項)?{

var?正常?=?{

cou _ left:“# cou _ left”,

cou_right:'#cou_right ',

寬度:?100,//?寬度

身高:?260,//?高度

top:?260,//?書眉

邊距:?50,//?雙面邊距

min_width:1200//?最小寬度

};

var?行動組。=?$.擴展(正常,選項),?l=$(ops.cou_left),?r = $(ops . cou _ right);

l.css({'width':ops.width?+?' px ',' height':ops.height?+?' px ',' background':'#800 ',' position':'fixed ',' left':ops.margin+'px'})。動畫({top:ops.top?+?px ' });

r.css({'width':ops.width?+?' px ',' height':ops.height?+?' px ',' background':'#800 ',' position':'fixed ',' right':ops.margin+'px'})。動畫({top:ops.top?+?px ' });

if($(窗口)。width()& lt;ops.min_width){

l . hide();隱藏()

}

}

})(jQuery);

  • 上一篇:我想做個網站,太原誰家做的好?
  • 下一篇:惡臭先輩是什麽電影
  • copyright 2024編程學習大全網