0

我完全不解。我一直在试图弄清楚这件事。当用户单击复选框时,我正在尝试更改标签的颜色。下面的代码在小提琴中工作正常,但在网站上不起作用。我在 . 还有什么可能导致这种情况吗?我应该注意什么?

HTML

<div class="product_checkbox_div">
<input type="checkbox" name="1" id="check1" value=""/>
<label class="product_ingredients_list">Yes</label>
</div>

CSS

.product_checkbox_div{padding-top:0.5%;padding-bottom:0.5%;vertical-align:top;}
.product_ingredients_list{font-family:Calibri;font-size: 1em;color: #101010;font-weight:     normal;vertical-align:top;}
.product_ingredients_list_1{font-family:Calibri;font-size: 1.15em;color: #f33;font-weight: normal;vertical-align:top;}

JAVASCRIPT

$( '.product_checkbox_div' ).on( 'click', 'input:checkbox', function () {
$( this ).next('label').toggleClass( 'product_ingredients_list_1', this.checked );
});

小提琴

谢谢

4

1 回答 1

2

干得好.......

http://jsfiddle.net/aqRrz/

$("document").ready(function () {

    $("input#check1").click(function () {

        if ($(this).is(':checked')) {

            $(this).next('label').addClass('product_ingredients_list_1');

        } else {

            $(this).next('label').removeClass('product_ingredients_list_1');

        }

    })

});
于 2014-03-27T20:29:45.247 回答