>> >> if ($('#warningmsg').size()) highlightWarningMsg(); >> >> Is that the "correct" way of testing if a jQuery object contains anything? > > You could also do: > if ($('#warningmsg')[0])
You could also say this: $("#warningmsg").each(highlightWarningMsg); Each won't call the fn at all unless the element exists. If that's the only place the fn is called, just drop an anonymous function there. Or you could turn it into a plugin and do this: $("#warningmsg").highlightMsg(); _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/