$("#id") retuning non-null value even if a tag with such an id does not exist
<p>I am doing </p>

<pre><code>var tag = $("#foo");
if(tag != null) {
 // do something
}
</code></pre>

<p>the thing is, if even if the tag does not exist when the script is first executed, the value of tag variable is non-null and hence it breaks the code.</p>

<p>Why is it happening?</p>
