jquery issue if checked change bg color

Posted by user3058067 on Stack Overflow See other posts from Stack Overflow or by user3058067
Published on 2014-05-27T15:12:09Z Indexed on 2014/05/27 15:25 UTC
Read the original article Hit count: 221

Filed under:
|
|

Hello i made a script that is supposed to change background when radio is selected. It works but when another radio is selected the previous still remains with the selected color. It works for checkboxes but not for radio.

<script type="text/javascript">
$(".table").change(function(){
  var c = this.checked ? "#18b9e7" : "#b6bf34";
  $(this).parent().css("background-color", c);
});
</script>

Here is a jsfiddle

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery