3 回答
well, you could try hacks like this....
$(':radio:disabled').removeAttr('disabled').click(function(){
this.checked=false;
});
this will select all disabled radio buttons and enabled it but when click, will not be checked...
demo
and on <select>
you could do like,
$('select:disabled').removeAttr('disabled').change(function(){
$(this).find('option').removeAttr('selected');
// this.value = this.defaultValue; // you may also try this..
});
只需将它们替换为您自己的更可控的 HTML/CSS 构造,à la Niceforms等。(酌情使用disabled或readonly属性作为后备)。
A suggestion rather an answer: you can associate an event with the state change of an element, and cancel the change.
You can do it the same way as the validate tools which allows to enter only digits or only some characters in <input type="text" /> fields. See a StackOverflow post about this.
Another solution is to put something in front of your controls. For example:
<div style="position:absolute;width:200px;height:200px;"></div>
<input type="radio" />
will make your radio button unclickable. The problem is that doing so will prevent the users to copy-paste text or using hyperlinks, if the <div/> covers the whole page. You can "cover" each control one by one, but it may be quite difficult to do.