單選按鈕選中、取消
阿新 • • 發佈:2019-01-18
attr inpu pro str on() dom false fun his
<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);
}
});
});
單選按鈕選中、取消