0
我试图触发单选按钮上的触发器,但无法让它工作。 它工作正常,如果我使用复选框,而不是我需要单选按钮。通过点击事件触发设置单选按钮?
单选按钮可以通过按下它或测试div来设置。如果单选按钮被改变,它应该触发触发器。
<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/