使RadioButtonList中选定的RadioButton不可单击但不禁用

Make the selected RadioButton in a RadioButtonList unclickable but not disabled

本文关键字:单击 RadioButton RadioButtonList      更新时间:2024-02-23

我有一个ASP.Net页面,上面有几个RadioButtonList控件。

我想以只读格式显示此页面,但我希望每个单选按钮列表中所选的单选按钮显示为"正常",即看起来不被禁用,但不允许单击单选按钮,因为我不希望修改该值。

我相信这个问题已经在某个地方得到了答案,但我的谷歌搜索目前让我失望了。。。

在单选按钮容器div的顶部覆盖一个div,最大z索引和alpha设置为max,这样它就会看起来透明。这使得单选按钮不可点击

试试这个http://jsfiddle.net/chintupawan/ztT5j/

要防止按钮也不可点击,可以使用div覆盖它们。

http://jsfiddle.net/heXQf/

<form>
    <div class="row">
        <div class="block"></div>           
<input type="radio" name="sex" value="male" id="rdo"/> Male<br />
<input type="radio" name="sex" value="female" id="rdo"/> Female
     </div>
</form> 
form{width:300px;position:relative;}
.block{width:100px;display:block;height:100px;position:absolute;top:0;}

    $('#rdo').click(function(e) {
    e.preventDefault();
});

试试这个jQuery:

$('.class-of-radio-button').click(function(e) {
    e.preventDefault();
});

Fiddle:http://jsfiddle.net/c_kick/Gkp2Z/

尝试这个

$("input[type!='radio'], select, textarea ").attr('disabled',true);
$("input[type='radio']").click(function(e){
     e.preventDefault();
});