Monday 13 February 2012

jQuery: check if a variable is defined

if($('#foo').length > 0) { alert("id 'foo' exists!"); } else { alert("id 'foo' doesn't exist!"); }

References

See also how to do the same with Javascript.

No comments:

Post a Comment