我需要一些关于 javascript 的帮助。
这是 JSFIDDLE 中代码的链接:http: //jsfiddle.net/Gopher69/B98kZ/4/
我的 JS 是:
$(document).ready(function() {
//add the Selected class to the checked radio button
$('[type=radio]').parent().addClass("selected");
//If another radio button is clicked, add the select class, and remove it from the previously selected radio
$('input').click(function() {
$('input:not(:checked)').parent().removeClass("radio validate-one-required-by-name product-custom-option").find("class").html("radio validate-one-required-by-name product-custom-option");
$('input:checked').parent().addClass("radio validate-one-required-by-name product-custom-option").find("class").html("radio validate-one-required-by-name product-custom-option active");
});});
我想调整单选按钮的背景颜色,就像我对 CSS 的悬停效果所做的那样。因此,当单选按钮处于活动状态时,我需要在类中添加“选中”之类的内容。
我找到了这篇文章,但我没有得到前言:jQuery Checkbox selection and change class
如果有人可以帮助我,我将非常感激。