jQuery:以面向对象的方式编写jQuery [英] jQuery: Writing jquery in an object oriented way
问题描述
我正在尝试以面向对象的方式编写所有查询代码.但是我不知道如何为每个点击功能和悬停功能等实现此功能.我也想知道:
I am trying to write all my query code in an object oriented way. But I don't know how to implement this for each click function and hover function etc. I also wanted to know:
- 以面向对象的方式编写查询有什么优势?
- 对于查询,什么是面向对象的方法还是普通方法更好的方法?
推荐答案
两个相反的问题,可以帮助您决定如何进行此操作:
Two counter-questions, that may help you deciding how to proceed on this:
-
为什么要这样做?是因为您最近了解到OOP很棒,并且想在任何地方使用它,还是您有编写OO jQuery的特定原因?请记住:只是因为技术(例如jQuery)或方法论(例如OOP)有时很棒,甚至在大多数情况下,甚至不是整个时期,它都不是很好时间.
您将如何(以及为什么)编写OO JavaScript?别忘了jQuery只是扩展javascript语言的库,仅此而已.很多时候,使用jQuery的javascript和不使用jQuery的javascript都适用相同的规则和推理.
How (and why) would you write OO javascript? Don't forget that jQuery is just a library extending the javascript language, nothing else. Many times, the same rules and reasoning apply for javascript with jQuery as for javascript without jQuery.
这篇关于jQuery:以面向对象的方式编写jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!