Select all labels in a form

advertisements

My problem is that i want to select all labels inside a form and remove a certain class.

What i have now is something like this:

<form id="frmCreateCase" name="frmCreateCase">
    <div id="radioSubjectName" class="radioButtons">
        <input type="radio" value="Information" id="radioSubjectName1" name="radioSubjectName" /><label for="radioSubjectName1">Information</label>
        <input type="radio" value="Sales" id="radioSubjectName2" name="radioSubjectName" /><label for="radioSubjectName2">Sales</label>
    </div>
    <div id="radioProductName" class="radioButtons">
        <input type="radio" value="WP" id="radioProductName1" name="radioProductName" /><label for="radioProductName1">WP</label>
        <input type="radio" value="FST" id="radioProductName2" name="radioProductName" /><label for="radioProductName2">FST</label>
    </div>
    <div id="radioStatusName" class="radioButtons">
        <input type="radio" value="STARTED" id="radioStatusName1" name="radioStatusName" /><label for="radioStatusName1">STARTED</label>
        <input type="radio" value="AWAITING REVIEW" id="radioStatusName2" name="radioStatusName" /><label for="radioStatusName2">AWAITING REVIEW</label>
    </div>
</form>

Then i initialize my button set to have nice looking buttons like this

$( "#radioSubjectName" ).buttonset();
etc.....

When clicked, these labels receive class 'ui-state-active'.

I want to create a functionality to loop all the labels and remove that class from each label. What i do now is something like this:

$("label[for='radioSubjectName1']").removeClass('ui-state-active');
$("label[for='radioSubjectName2']").removeClass('ui-state-active');
etc...

Is there an easier way to loop all these labels that are child to my form and do this removal of class?


how about

$('form#frmCreateCase label.ui-state-active').removeClass('ui-state-active')

this will remove these classes from the ones that have it.