confusion over simple variable declaration jQuery "$variable" vs javascript "var"
<p>I have this simple ghost text implementation:</p>

<p>HTML code:</p>

<pre><code>&lt;div id="searchPanel"&gt;
     &lt;form method="get" id="searchBox" action="somePage.php"&gt;
     &lt;input class="ghText" type="text" name="query" value="search here"/&gt;
     &lt;/form&gt;
&lt;/div&gt;
</code></pre>

<p>jQuery code:</p>

<pre><code>$(document).ready(function(){
        $txtField = "#searchPanel form input.ghText";
        var value = $($txtField).val();
        $($txtField).focus(function(){
            if($(this).val() == value)
                $(this).val("").removeClass("ghText");
        });
        $($txtField).blur(function(){
            if($(this).val()==""){
                $(this).val(value).addClass("ghText");
            }
        });
});
</code></pre>

<p>The example above is not going to work. When the user focuses the cursor on the search bar, the class "ghText" wont be removed for some reason.</p>

<p>However now if I change the "var value" (variable initialization) and "value" with 
"$value" as in:</p>

<pre><code>$value = $($txtField).val(); 
$(this).val($value).removeClass("ghText");
$(this).val($value).addClass("ghText");
</code></pre>

<p>everything works perfectly. </p>

<p>I can just go to sleep and not worried too much about it..but I am very curious why something like that can happen?  </p>

<p>is it because of the "this" not referreing to the right object, or is it because i tried storing jQuery object in non-jQuery variable or is it about something else..can somebody point out to me what was wrong? I have always thought that "var x" is the same as "$x"..?</p>
