1

Can anyone help out with what im doing wrong here?

DEMO

HTML

<div id="usercurrentccbox">
    <div class="cardChoice">
        <label for="mastercard"></label>
    </div>
</div>

JQUERY

$(document).ready(function(){
    var cct = "mastercard";
    //$('#usercurrentccbox .cardChoice label[for=mastercard]').addClass("active");
        $('#usercurrentccbox .cardChoice label[for="'+cct+'"').addClass("active");
});

CSS

    label{
    position:relative;
    float:left;
    width:200px;
    height:170px;
    border:1px solid #000;
}

label.active{
    border: 1px solid #d6d6d6;
}
0

2 Answers 2

8

You seem to be missing a closing ] in your selector.

// corrected
$('#usercurrentccbox .cardChoice label[for="'+cct+'"]').addClass("active");
//                                                  ^ over here
Sign up to request clarification or add additional context in comments.

1 Comment

Haha, my eyes just happened to land there first thing.
2
        $('#usercurrentccbox .cardChoice label[for="'+cct+'"]').addClass("active");

You just forgot the closing ]

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.