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();
});
精彩评论