标签:
<html lang="en"> <head> </head> <body> <div class="" style="width: 0px;height: 50px;border: 3px solid black" id="div1"> </div> <script type="text/javascript"> var i=0; function Adder(){ Adder.prototype.styleAdder=function(divId,width) { document.getElementById(divId).style.width = width+"px"; return this;//this总是指向Adder()的实例,链式调用关键点 }; } var adder=new Adder(); adder.styleAdder("div1",50).styleAdder("div1",160).styleAdder("div1",360); </script> </body> </html>
标签:
原文地址:http://www.cnblogs.com/zjsy/p/5618715.html