title: Adding/removing classes with jquery
body: <p>I am trying to change the font size of a webpage. I have specified three sizes: </p>
  
  <ul>
  <li>Small </li>
  <li>Medium</li>
  <li>Large</li>
  </ul>
  
  <p>Based on what the user clicks the html font size should become the size he chooses.</p>
  
  <p><code>#small</code>, <code>#med</code>, <code>#large</code> are three paragraph elements.</p>
  
  <p><code>medium</code>, <code>small</code>, <code>large</code> are three classes for CSS.</p>
  
  <p>My code is:</p>
  
  <pre><code>enter code here
  
  
  
  &lt;script&gt;
                  $(document).ready(function(){
                      $("#small").click(function(){
                          if($("p").hasClass('large'))
                          {
                           $("p").removeClass("large").addClass("small");
                          }
                          else
                          {
                              $("p").removeClass("medium").addClass("small");
                          }
                          });
                      $("#med").click(function(){
                          if($("p").hasClass('small'))
                          {
                              $("p").removeClass("small").addClass("medium");
  
                          }
                          else
                          {
                              $("p").removeClass("large").addClass("medium");
                          }
  
                      });
  
                      $("#large").click(function(){
                          if($("p").hasClass('small'))
                          {
                              $("p").removeClass("small").addClass("large");
                          }
                          else
                          {
                              $("p").removeClass("medium").addClass("large");
                          }
  
                      });
  
  
                  });
              &lt;/script&gt;
  </code></pre>
  
  <p>I don't think its working perfectly. So if anyone could show where i am going wrong will be of great help.</p>