单选按钮选中、取消

<input type="radio" name="xxx">
$(function() {
$(‘input:radio’).click(function () {

    1. //alert(this.checked);
    2. var domName = $(this).attr('name');
    3. var $radio = $(this);
    4. // if this was previously checked
    5. if ($radio.data('waschecked') == true) {
    6. console.log($radio.data('waschecked') == true);
    7. $radio.prop('checked', false);
    8. //$("input:radio[name='radio" + domName + "']").data('waschecked',false);
    9. $radio.data('waschecked', false);
    10. } else {
    11. console.log($radio.data('waschecked') == true);
    12. $radio.prop('checked', true);
    13. //$("input:radio[name='radio" + domName + "']").data('waschecked',true);
    14. $radio.data('waschecked', true);
    15. }
    16. });
    17. });
posted @ 2019-01-18 17:51  明天,你好啊  阅读(637)  评论(0编辑  收藏  举报