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/