0

私は完全に困惑しています。私はこのことを永遠に理解しようとしてきました。ユーザーがチェックボックスをクリックしたときにラベルの色を変更しようとしています。以下のコードはフィドルでは正常に動作しますが、Web サイトでは動作しません。の直前に Google API を呼び出します。それを引き起こしている可能性のあるものは他にありますか?気をつけるべきことはありますか?

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;}

ジャバスクリプト

$( '.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 に答える