这是一个现场演示。
我有以下html:
<div class="Q">
<div id="Q3"><span>1. </span>Which of the following is a string?</div>
<div class="A"><input type="radio" id="Q3A1Correct" /></div>
<div class="A"><input type="radio" id="Q3A2Correct"/></div>
<div class="A"><input type="radio" id="Q3A3Correct" checked/></div>
<div class="A"><input type="radio" id="Q3A4Correct" /></div>
</div>
<div class="Q">
<div id="Q1"><span>2. </span>Which of the following have the same meaning?</div>
<div class="A"><input type="checkbox" id="Q2A1Correct" /></div>
<div class="A"><input type="checkbox" id="Q2A2Correct" /></div>
<div class="A"><input type="checkbox" id="Q2A3Correct" checked/></div>
<div class="A"><input type="checkbox" id="Q2A4Correct" /></div>
</div>
而且我想阻止用户更改选择,而不禁用输入。所以我这样做了:
$(':checkbox[id$="Correct"]').click(function (event) {
event.preventDefault();
});
$(':radio[id$="Correct"]').click(function (event) {
event.preventDefault();
});
它适用于所有浏览器上的复选框,但它适用于 IE9 和 Opera 的收音机,但不适用于 FF 3.6.17 和 Chrome。
所以我很好奇为什么会这样,但我还需要解决它以使其适用于所有浏览器。
谢谢。