<input type="radio" name="xxx">
$(function() {
$(‘input:radio’).click(function () {
//alert(this.checked); var domName = $(this).attr(‘name‘); var $radio = $(this); // if this was previously checked if ($radio.data(‘waschecked‘) == true) { console.log($radio.data(‘waschecked‘) == true); $radio.prop(‘checked‘, false); //$("input:radio[name=‘radio" + domName + "‘]").data(‘waschecked‘,false); $radio.data(‘waschecked‘, false); } else { console.log($radio.data(‘waschecked‘) == true); $radio.prop(‘checked‘, true); //$("input:radio[name=‘radio" + domName + "‘]").data(‘waschecked‘,true); $radio.data(‘waschecked‘, true); } });});原文:https://www.cnblogs.com/ming-blogs/p/10289036.html