tags:

views:

38

answers:

2
<input type='radio' name='specific_consultant' id='specific_consultant_no' value='no'>No</input>

hii. i have a radio button like this . on click of this radio button , i need to change text color of text like No .. how do i do it..

+4  A: 

You could use the css function:

$(function() {
    $('#specific_consultant_no').click(function() {
        $(this).css('color', 'red');
    });
);
Darin Dimitrov
+2  A: 
$(document).ready(function() {
    var button = $('#specific_consultant_no');
    button.click(function() {
        button.css('color', 'FOO');
    });
});

if you want to reuse the method, you can do eg.

var colorMethod = function() {
    $(this).css('color', 'FOO');
};
$(document).ready(function() {
    var button = $('#specific_consultant_no');
    button.click(colorMethod);
});

you can also use the addClass and removeClass methods, to be more flexible!

Andreas Niedermair
i added like $('#specific_consultant_no').css('color','red'); but did not work ....
pradeep
is your id unique on your page - following the standards, it has to be!
Andreas Niedermair
yes its according to standards .. that id is used only once in tht page..
pradeep
does your assignment of the css-attribute be in a click-eventHandler? please support more code, so that i can help you!
Andreas Niedermair