jQuery 教程/书籍将教如何编写这样的代码
如果我在网站上看到很酷的效果,我会查看 jquery 的源代码,通常我可以理解它,但是,我正在查看 http://www.mckinsey.com 并查看了用于制作页面幻灯片的 jQuery 源代码:http://www.mckinsey.com/assets/dotcom/js/home.js
我似乎无法理解这个 jQuery 代码是如何编写的或者它的作用,但是,我确实明白它是以更好的方式编写的,并且可以正确维护,因为所有内容都不在 document.ready()
函数内
有人可以稍微分解一下这段代码来解释一下吗(我'我只关心滑块而不是cookie)
是否有教程/书籍展示如何编写/理解以这种方式编写的 jQuery 代码。
If I see a cool effect on a website I view the source of jquery and usually I can wrap my head around it ,however, I was looking at the slider for http://www.mckinsey.com and viewed the jQuery source that is used in doing the page slide: http://www.mckinsey.com/assets/dotcom/js/home.js
I can't seem to understand how this jQuery code is written or what it does, though, I do understand that it is written in a better fashion and can be maintained properly since everything is not inside the document.ready()
function
Can someone break this code down a little to explain (I'm just concerned with slider not, not cookies)
Are there tutorials/books that show how to write/understand jQuery code written in this manner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种方法和其他类似方法被称为“设计模式”。这个特定的模式似乎是命令模式。以下链接对更流行的模式、它们为何有用以及代码示例进行了很好的解释:
http: //addyosmani.com/resources/essentialjsdesignpatterns/book/
This method and others like it are known as 'design patterns'. This particular one appears to be the Command Pattern. The following link has a great explanation of the more popular patterns, why they're useful and code examples:
http://addyosmani.com/resources/essentialjsdesignpatterns/book/