I have one input field with variable width, like small, large, medium. I have a CSS style for this.
Example:
case 1: <input type="text" id="a1" class="title small required" />
case 2: <input type="text" id="a1" class="title medium" />
case 3: <input type="text" id="a1" class="title large required" />
Meanwhile, I have a field select:
<select id="b1">
<option value="small">Small</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
</select>
Now I need to check that the field inputhas a class smallor mediumor large
and set the corresponding block selectas selected. In jQuery, I directly set the selected values as medium, but still the dropdown shows small.
How to check if a field has inputany of these classes using a function hasClass()? Can we check it at a time?
source
share