1

Hi I really could do with a point in the right direction with this question.

I'm trying to fathom object orientated javascript, but am having trouble getting my head around binding dom elements to objects.

I would like to make a little animated widget type thing for my web page. the widget will be just simple drop down tabs , (like tabs from an actual folder) I want the tab to drop down a bit with a mouseover event then raise up with mouseout.

here is my current implementation, it doesnt work well at the moment it's just a mock up http://bombinglish.com/

I want to make a class for the tabs , which will include the open and close animation methods, methos to add events, and other necessary fields. then instanciate a new object for each tab. but how do I do I tell each object that it must must respond to the corresponding mouse events, or to put it another way how do I bind the DOM element to the object?

4

1 回答 1

1

如果您仅将 Javascript 用于表示逻辑,那么我认为尝试使用 OO 是不值得的。

如果你在每一页的顶部都有它,你可以简单地用一个唯一的类名标记选项卡。然后在您的 Javascript 文件中,使用该类名在每个 DOM 元素上绑定一个 mouseover 事件。

也许,其他人对此有不同的看法。

于 2013-05-14T21:09:30.760 回答