jQuery always returns a jQuery object.
it's never null nor are any of the items in it null.

it just may have no items.

if ($('#categories').length == 0) { alert('foo'); }


On 5/17/07, Yansky <[EMAIL PROTECTED]> wrote:


Hi, I was just curious as to what jQuery returns instead of 'null'
when it can't find an element?

e.g. if I wanted to run some code if a certain element was on the
page, this doesn't return null:
if ($('#categories') != null) { alert('foo'); }

but getting out of the jQuery object does:
if ($('#categories')[0] != null) { alert('foo'); }


So if it doesn't return 'null', what does it return?




--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ

Reply via email to