Need help writing js function that changes the class of the button that calls it
<p>I'm not very good with js, but basically I have a button </p>

<pre><code>&lt;%=button_to_function "✓", checkButton(), :class =&gt; "buttonGrey"%&gt;
</code></pre>

<p>that is calling a js function I made. However I am getting errors in my syntax for the function.</p>

<pre><code>function checkButton()
{
if (this.className="buttonGrey") {
    this.removeClass('buttonGrey');
    this.addClass('buttonGreen');
}

if (this.className="buttonGreen") {
   this.removeClass('buttonGreen');
   this.addClass('buttonGrey');
}
}
</code></pre>
