title: passing multiple variables to function in order to add/remove class Jquery/Javascript
body: <p>I'm trying to first clear the class of all <code>options</code> and then add a class to the option with the corresponding letter.
  Here's my function:</p>
  
  <pre><code>function setAnswer(b, c){
        $('#'+b+' .option').removeClass("answer");
        $('#'+b+' .option'+c).addClass("answer");  
    }
  </code></pre>
  
  <p>and the form </p>
  
  <pre><code> &lt;div id="belh" class="options"&gt;
                  &lt;label&gt;a.&lt;/label&gt;&lt;input class="option optiona"&gt;&lt;input onClick="setAnswer(this.parentnode.id, this.classname)" type="radio" class="a" name="answer"&gt;&amp;nbsp;
                  &lt;label&gt;b.&lt;/label&gt;&lt;input class="option optionb"&gt;&lt;input onClick="setAnswer(this.parentnode.id, this.classname)" type="radio" class="b" name="answer"&gt;
                  &lt;div class="clear"&gt;&lt;/div&gt;
                  &lt;label&gt;c.&lt;/label&gt;&lt;input class="option optionc"&gt;&lt;input onClick="setAnswer(this.parentnode.id, this.classname)" type="radio" class="c" name="answer"&gt;&amp;nbsp;
                  &lt;label&gt;d.&lt;/label&gt;&lt;input class="option optiond"&gt;&lt;input onClick="setAnswer(this.parentnode.id, this.classname)" type="radio" class="d" name="answer"&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>the id for the div <code>belh</code> changes dynamically so I pass <code>this.parentnode.id</code> onto variable <code>b</code> in the function so i can do this:</p>
  
  <pre><code> $('#'+b+' .option').removeClass("answer");
  </code></pre>
  
  <p>remove class from all option elements<br>
  now i pass <code>this.classname</code> to <code>c</code> so i can get the letter (a,b,c,d) to use here:</p>
  
  <pre><code>$('#'+b+' .option'+c).addClass("answer");
  </code></pre>
  
  <p>so that if the radio box with class <code>c</code> is clicked, all fields with class <code>option</code> within the div <code>belh</code> will lose the class answer, if they have it. then the field with class <code>optionc</code> will have class <code>answer</code> added to it. (because: <code>$('#'+b+' .option'+c).addClass("answer");</code>). For some reason my function isn't working. I think I'm passing the variables in the wrong way.</p>