Can anyone help out with what im doing wrong here?
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
ngplayground
21.8k37 gold badges98 silver badges176 bronze badges
2 Answers 2
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
Richard Neil Ilagan
14.8k6 gold badges52 silver badges68 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Richard Neil Ilagan
Haha, my eyes just happened to land there first thing.
$('#usercurrentccbox .cardChoice label[for="'+cct+'"]').addClass("active");
You just forgot the closing ]
answered Jun 26, 2012 at 13:03
johnmadrak
8255 silver badges7 bronze badges
Comments
lang-js