Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

isset in jQuery? [duplicate]

Possible Duplicate:
Finding whether the element exists in whole html page

i would like make somethings:

HTML:

<span id="one">one</span>
<span id="two">two</span>
<span id="three">three</span>

JavaScript:

if (isset($("#one"))){
   alert('yes');
}

if (isset($("#two"))){
   alert('yes');
}

if (isset($("#three"))){
   alert('yes');
}

if (!isset($("#four"))){
   alert('no');
}

LIVE:

http://jsfiddle.net/8KYxe/

how can I make that?

like image 490
Paul Attuck Avatar asked Sep 23 '11 08:09

Paul Attuck


1 Answers

if (($("#one").length > 0)){
   alert('yes');
}

if (($("#two").length > 0)){
   alert('yes');
}

if (($("#three").length > 0)){
   alert('yes');
}

if (($("#four")).length == 0){
   alert('no');
}

This is what you need :)

like image 173
Snicksie Avatar answered Oct 19 '22 23:10

Snicksie