On Jul 3, 2009, at 3:48 AM, olsch01 wrote:


I also read about using $ or j if you're variable stores a jQuery
object.

Maybe this might sound stupid, but what if you first do something like
this:

var $showFeedback = $('#showFeedback' +spanIdNo);

(or var jShowFeedback = $('#showFeedback' +spanIdNo); respectively)

And if you then want to store the height of that element, do you use $
or j again (-> $showFeedbackHeight = $showFeedback.height();), or do
you use a "regular" variable name because it's not a jQuery object but
an attribute?

If the value is numeric, which it is in this case, I wouldn't use the $ or j. I only use $variableName when the value is a jQuery object.

var $showFeedback = $('#showFeedback' +spanIdNo);
var showFeedHeight = $showFeedback.height();

Of course, there isn't really a "right" way. It's just a convention (though a useful one).

In case you're interested, this convention was first suggested by Michael Geary back in 2006.

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to