我试图阻止单选按钮在用户点击时发生变化,它在使用标准 jQuery 时有效,但是当你包含 jQuery Mobile 时它似乎不起作用,在 jQuery Mobile 中我还需要做些什么吗?
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="trade-direction" id="buy" value="B" checked="checked" />
<label for="buy">Buy</label>
<input type="radio" name="trade-direction" id="hold" value="H" />
<label for="hold">Hold</label>
<input type="radio" name="trade-direction" id="sell" value="S" />
<label for="sell">Sell</label>
</fieldset>
$('[name="trade-direction"]:radio').click(function(event) {
if(!confirm("Do You Want To Change?")) {
event.preventDefault();
}
});
下面是 jsFiddle 中代码的链接。