Link to home
Start Free TrialLog in
Avatar of Starr Duskk
Starr DuskkFlag for United States of America

asked on

Check if an element is defined

I have this code...

        var portfolio_item = $$('.portfolio_item');

Following is a bunch of stuff manipulating items within this  item, but if the item is not defined on the page, I want it to skip that stuff.
How can I do an if statement that makes sure this item is even on the page first?
ASKER CERTIFIED SOLUTION
Avatar of Pawel Witkowski
Pawel Witkowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Starr Duskk

ASKER

Thanks!
Everything I was reading was saying to check the length...
http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html
if ($("#some").length)
http://jqueryfordesigners.com/element-exists/
$('element').length == 0;
And that errored.
Thanks again! Yours works!
 
 
great!