Hi, > var element; > if ( (element=$('#someID')[0]) ) { > /* element exists */ > } else { > /* damn... */ > }
I'd prefer var e if( (e=$('#someID')).length ) { // element Exists } else { // element does not exist } Usually you whant to know if an Element exists to create it otherwise, so I often have code like this: if( ! (e=$('#someID').length) ) e = $('<p id="someID">asdf</p>').appendto('#myParent'); e.hide(); Christof