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;
}
asked Jun 26, 2012 at 13:00
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
answered Jun 26, 2012 at 13:02
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 ]

answered Jun 26, 2012 at 13:03

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.