SO - 21965642

by Arun P Johny

HTML

<div class="test">Information that I want to be coloured</div>
<div>
    <label><input type="radio" id="A" name="RadioGroup1" value="Y"/>Yes</label>
    <br/>
    <label><input type="radio" id="B" name="RadioGroup1" value="N"/>No</label>    
</div>

CSS

.classGreen {

    color: green

}

.test {

    font-size:24px

}

.classRed {

    color: red

}

JavaScript

jQuery(function () {
    $('input[type=radio][name=RadioGroup1]').change(function () {
        $('.test').toggleClass("classGreen", this.value == 'Y');
        $('.test').toggleClass("classRed", this.value != 'Y');
    })
})