0

Hi I want to disable a check box first, then i want to add a css property. I have written the below code. By this code the check box is disabled but the css property is not added.

 $("input:radio,input:checkbox").each(
     function (nitem,obj){        
         if (labelTag[0].nodeName == 'LABEL'){
             labelTag.click(function(ev){
                 $(this).prev().checkboxradio('disable').css("color","red");
        });
    }
});

HTML code:

<div class="simple-checkbox chk">
     <input type="checkbox" id="billingaddress" class="radio">
         <label class="gray enableExpressCK" for="billingaddress">Enable Express Checkout</label>
 </div>

jsFiddles here

1
  • sorry I didn't get you... when the checkbox is checked you want to add a css property to the next label Commented Dec 19, 2013 at 4:56

3 Answers 3

1

Try this http://jsfiddle.net/j93Vu/

$("input:radio,input:checkbox").change(function () {
    $(this)
        .prop('disabled', true)
        .next('label')
            .css('color', 'red');
});
Sign up to request clarification or add additional context in comments.

Comments

1

Just a minor update:

$("input:radio,input:checkbox").change(function () {
    $(this)
        .attr('disabled', 'disabled')
        .next('label')
            .css('color', 'red');
});

Comments

0

Your javascript is NOT working:

ReferenceError: labelTag is not defined if (labelTag[0].nodeName == 'LABEL') {

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.