0

Im trying to fire a trigger on a radio button, but cant get it to work. It works fine if i use a checkbox instead, but i kinda need the radio button.

The radio button can be set by pressing it, or the Test div. If the radio button is changed it should fire the trigger.

<div class="testing">  
  <div class="test">Test</div>
  <input type="radio">
</div>

$(".test").on("click", function() {
var radio = $(this).closest(".testing").find("input[type='radio']");
    if (!radio.prop("checked")) {
        radio.prop("checked", true);
    } else {
        radio.prop("checked", false);
    }
})

  $(".testing").on("change", function() {
  $(".test").html("weee");
});

https://jsfiddle.net/fbmod5ca/

0

1 Answer 1

1

Use trigger('change') to trigger event explicitly

radio.prop("checked", true).trigger('change');

Updated Fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.