[jQuery] Style question: holding on to an element

[jQuery] Style question: holding on to an element


I've been looking at the source code for the Dim Screen plugin
http://docs.jquery.com/Plugins/dimScreen
Two things caught my eye. The plugin always refers to the overlay div by
id. Is there a reason not to close over a variable referring to the
overlay instead? Then, when the overlay is hidden, it is also removed
from the DOM. Wouldn't hiding be enough instead of possibly repeatedly
adding and removing the overlay?
More generally, I'm still rather new to jQuery, I'm more used to
Prototype. One thing I noticed immediately is that jQuery feels much
less OO than Prototype does. For DOM access and manipulation I actually
prefer jQuery's set-oriented approach. However, I value OO-style highly
as a means of modularizing code. In that regard, it seems to me, that
too many plugins are guilty of dumping functions into the jQuery
namespace.
Michael
--
Michael Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/