Hi Please check below code -
HTML
<div class="manage-user-freind" style="line-height:18px; cursor:pointer;">
<span style="color:blue;">
<img src="'+pageUrl+'/img/user-16x16.png" height="14" style="float:left; padding-top:2px;" /><input class="chk" type="checkbox" value="10" />pieter
</span>
</div>
<div class="manage-user-freind" style="line-height:18px; cursor:pointer;">
<span style="color:blue;">
<img src="'+pageUrl+'/img/user-16x16.png" height="14" style="float:left; padding-top:2px;" /><input class="chk" type="checkbox" value="12" />john
</span>
</div>
JQuery
$('.manage-user-freind').click(function(){
$(this).toggleClass('clicked',function(){
$('.chk').prop('checked', true);
});
});
CSS
.clicked {
background-color: yellow;
}
I have used toggleClass() function. toggleClass
is working fine but all the check-boxes clicked also not unchecked the current checkbox .
I need when I will click any div first show that div in yellow color along with current checkbox checked. Again clicking on that yellow color div will remove and also checkbox will unchecked.
Thanks.
Sorry for my English wording. :(
Aucun commentaire:
Enregistrer un commentaire