title: Is there a way to do this with basic JS DOM?
body: <p>I need to apply/remove to an input field according to a user's selection in a separate drop down form - but I can't figure out how to target the input's class. </p>
  
  <p>I need to add/remove the 'pageRequired' class from this input:</p>
  
  <pre><code>&lt;input  type="text" title="Company Required" name="customfields-tf-2-tf" class="inputclass pageRequired textInput" id="customfields-tf-2-tf" /&gt;
  </code></pre>
  
  <p>When the user selects one of two options from a drop down field. For example:</p>
  
  <pre><code>&lt;select class="dropdown" name="customfields-s-1-s" id="customfields-s-1-s" &gt;
  &lt;option value="Owner"&lt;?php if(in_array("Owner",$temp_values)) { ?&gt; selected='selected'&lt;?php } ?&gt;&gt; Owner&lt;/option&gt;
  &lt;option value="Broker"&lt;?php if(in_array("Broker",$temp_values)) { ?&gt; selected='selected'&lt;?php } ?&gt;&gt; Broker&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>If the user selects broker than I want to add the pageRequired class to the first input field and remove it if the user selects Owner.</p>
  
  <p>EDIT- Ok, so here is the code I am working with:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function changeClass(myDropdown) {
     if (#customfields-s-1-s.selectedIndex == 1 ) {
         $('#customfields-tf-2-tf').addClass('pageRequired');
     }
     else {
        $('#customfields-tf-2-tf').removeClass('pageRequired');
     }
  }
  &lt;/script&gt;
  </code></pre>