开发者

radio button read only without fading

Is it possible 开发者_如何学Pythonto make a radio button read only without fading ?


AFAIK, you can't control it. It is up to browser unfortunately.

And poeple on the Web are used to the style of the disabled fields, changing it wouldn't that much accessible (or standard) any way.


As most of the people before, I don't really see a good use of it, but if you need it, here's a hack:

Include jquery javascript on your page and add class attributes to your radios:

<input checked="checked" name="n" value="1" type="radio" class="rdonly checked" /> 
<input type="radio" name="n" value="2" class="rdonly"/> 

And add the javascript hack:

$(document).ready(function() {
  $("input.rdonly").change(function() {
    $('input.checked').attr('checked', true);
  });
});

this will make all the radios with "checked" class instantly become selected when a user tries to select any radio with "rdonly" class. It looks just like was read only, but not faded.

I hope this is what you're looking for, but then again, I think I'd advise against it. Cheers


Using jQuery :

$('#radio-id').change(function(event){
    event.preventDefault();
    return false;
});

But like others said, I don't see the point, and I don't think it's a good idea...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜