无法取消选中单选按钮 [英] unable to uncheck the radiobutton

查看:164
本文介绍了无法取消选中单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击单选按钮时,它始终处于选中状态.我无法取消选中单选按钮正在搜索并尝试

Hi when i click the radion button ,It always checked.I cannot uncheck the radion button am serching and try How to check/uncheck radio button on click? this link.

问题

我只能检查一次,一旦我单击取消选中它总是取消选中不能正常工作 代码

I can check only once,once i click uncheck it always uncheck cannot work properly code

  <input value='' type='radio' id='one' onClick="getCurrentLocation()"/>

   $('input[type=radio]').click(function(){

    if (this.previous) {
        this.checked = false;
    }
    this.previous = this.checked;
});

推荐答案

这是您唯一的单选按钮吗?

Is it your the only radio button?

开发了单选按钮,用于保留一组可能的状态.

Radio buttons vere developed for keeping one of possible states from the set.

因此,如果只有一个单选按钮,请选中复选框.

如果其中有多个-请选择一些默认值以取消选中当前选定的内容. 但是,如果您单击该收音机中的另一个收音机,则无需特殊代码即可对其进行检查.

If you have several of them - choose some default one for unchecking currently selected. But if you click on another radio from the set, it will became checked without need of special code.

(据我所知,无法通过单击鼠标在浏览器中取消选中单选按钮,因此我也不希望脚本产生这种行为)

(As far as I remember, there was no way to uncheck radio-button in browser with mouse click on it, so I don't expect such behavour from scripts as well)

对于复选框,您不需要特殊的代码即可在单击时取消选中它-在所有浏览器中,这都是默认行为!

For checkbox you don't need special code to uncheck it on click - it's default behavour for them in all browsers!

如果仅是设计问题,则可以使用空白和已选中单选按钮的IMG,然后onClick更改图像.在这种情况下,您可以将状态保留在隐藏的输入字段中.

If it's only dessign question, then you can use IMG of empty and checked radio buttons, and onClick change the image. In this case you can keep your state in hidden input field.

但这会让您的用户感到困惑...

But it will be confusing for your users...

这篇关于无法取消选中单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆