Disable checkbox when selecting next

Asked

Viewed 30 times

0

I have a problem related to hidden div that is presented when selecting the check, as I cannot use the radio button for a function that is being used, I need to run in the checkbox, but when changing from checkbox the previous div remains enabled, the code is here in the http://jsfiddle.net/hqLz4kb7/2/

How can I fix this?

1 answer

0


Every time you give show() in a div, give Hide() in all other.

$("#add-festa-p").change(function() {
  if ($(this).prop('checked')) {
    $("#add-festa-p-div").show();
    $("#add-festa-k-div").hide();
    $("#add-festa-s-div").hide();
    console.log("Mostra a DIV");
  }
});

$("#add-festa-k").change(function() {
  if ($(this).prop('checked')) {
    $("#add-festa-k-div").show();
    $("#add-festa-p-div").hide();
    $("#add-festa-s-div").hide();
    console.log("Mostra a DIV");
  }
});

$("#add-festa-s").change(function() {
  if ($(this).prop('checked')) {
    $("#add-festa-s-div").show();
    $("#add-festa-k-div").hide();
    $("#add-festa-p-div").hide();
    console.log("Mostra a DIV");
  }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.