In jquery: Use attr(“class”) value as a selector?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4096834/in-jquery-use-attrclass-value-as-a-selector">In jquery: Use attr(&ldquo;class&rdquo;) value as a selector? </a>  </p>
</blockquote>



<p>I have fields with multiple classes. I want to use one of those classes as a selector, how do I do this?</p>

<p>generic example:</p>

<pre><code>&lt;input id="from"/&gt;&lt;div class="error from"&gt;errormessage&lt;/div&gt;
&lt;input id="to"/&gt;
&lt;div&gt;&lt;input id="when" /&gt;&lt;/div&gt;&lt;div class="error when"&gt;errormessage&lt;/div&gt;
</code></pre>

<p>Because ther is a div.error with the class from, I want to add a certain class to input#from and the same goes for the input called when.
Note that "when" is wrapped in a div. Several variations like this are necessary for the page. Therefore, tree-traversal is not a suitable solution.  </p>
