jQuery: remove class once element is clicked
<p>I am stuck on a little jQuery problem. I have a collection of links (more than 50) generated from a php loop. When a user clicks on a link, the jQuery load event is called, and a php/mysql script (called page.php in the example below) is loaded into an empty div on the page.</p>

<p>I would like the class (".classy") to removed from the &lt; a > tag and replaced with another class (".newclass"). This is so that the information is loaded only on the first click. </p>

<p>The html:</p>

<pre><code>&lt;a class='classy' name='marvin'&gt;Click to toggle info&lt;/a&gt;
&lt;div id='marvin'&gt;&lt;/div&gt;
</code></pre>

<p>The jQuery:</p>

<pre><code>$(document).ready(function(){
    $(".classy").click(function(){
        var foo = $(this).attr("name");
        $("#"+foo).load("page.php?id="+foo).slideToggle('fast'); 
        $(this).removeClass('classy');
        $(this).addClass('newclass');
        return false;
    });
});
</code></pre>

<p>Thanks!</p>
