Hi..
I have a group of checkboxes and I want to apply a style to checked checkbox and remove the style of all other boxes.Here only one checkbox should be cheked at a time.
The code I used as follows
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".item").click(function(e) {
//$(".item").each( function() {
$(".subscribe").attr('checked', false);
var checkbox = $(this).find(":checkbox"),
checked = checkbox.is(":checked");
//alert(checkbox);
//checkbox.prop("checked", false);
if (checked) {
$(this).attr('checked','checked');
$(this).css("background-color", "#d1d1d1");
} else {
$(this).css("background-color", "#03d100");
}
checkbox.prop("checked", !checked);
});
$('.item :checkbox').click(function() {
$(this).parent('li').click();
//})
})
});
</script>
<ul class="col-1">
<li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="Email" id="subscribe_0" />
<label for="">Check Up</label>
<span class="float-r">$19</span>
</li>
<li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="SMS" id="subscribe_1" />
<label for="">Check Up</label>
<span class="float-r">$19</span>
</li>
<li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="Radio" id="subscribe_2" />
<label for="">Check Up</label>
<span class="float-r">$19</span>
</li> <li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="Radio" id="subscribe_3" />
<label for="">Check Up</label>
<span class="float-r">$19</span>
</li>
</ul>