I've just been wondering if jQuery has some syntactic sugar for checking 
if an element exists. I know the following works:
--------------------------------------------------------
if ($('#my-element').length) {
     // #my-element exists
}
--------------------------------------------------------
but is there also something similar to the following?:
--------------------------------------------------------
if ($('#my-element').exists()) {
     // #my-element exists
}
--------------------------------------------------------
I'm asking because I know this was one of the things I was initially 
unsure about when learning jQuery and I just had a one of my many jQuery 
converted friends ask me about it again. So is anybody else thinking 
some syntactic sugar could be helpful here? Or what do you think about:
--------------------------------------------------------
$('#my-element').is('*') ?
--------------------------------------------------------
(Besides that it's probably inefficient *g*)

-- Felix
--------------------------
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de

Reply via email to