开发者

Change text color using jquery

开发者 https://www.devze.com 2023-01-01 09:00 出处:网络
I have a radio button like this <input type=\'radio\' name=\'specific_consultant\' id=\'specific_开发者_Go百科consultant_no\'

I have a radio button like this

<input type='radio' name='specific_consultant' id='specific_开发者_Go百科consultant_no' 
                                                                      value='no'>No</input>

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


$(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!


You could use the css function:

$(function() {
    $('#specific_consultant_no').click(function() {
        $(this).css('color', 'red');
    });
);


$("#myButton").on('click', function () {
        $(this).toggleClass('green');
        $("#result").toggle();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号