我使用iCheck创建现代单选按钮,有四个选项。当用户更改单选按钮时,我会弹出确认消息"您确定吗?"
如果确认返回false,我想支持上一个单选按钮,但现在它不会回到上一个收音机。
这是代码的一部分:
<form action="#" method="post">
<div style="padding-left:20px; line-height:2;">
<input type="radio" id="main-category1" name="main-category" value="1" > 1. <br>
<input type="radio" id="main-category2" name="main-category" value="2" > 2. <br>
<input type="radio" id="main-category3" name="main-category" value="3" > 3. <br>
<input type="radio" id="main-category4" name="main-category" value="4" > 4. <br>
<input type="radio" id="main-category5" name="main-category" value="5" > 5. <br>
</div>
</form>
<scirpt>
$('input').on('ifClicked', function(event){
msg = confirm('Are you sure?');
var cual= this;
if(msg == false) {
$('#main-category3').iCheck('check'); // It's check to new value and check to 3rd radio, but I want to check only 3rd radio.
}
});
</script>
答案 0 :(得分:0)
<script>
$('input').on('click', function(event) {
msg = confirm('Are you sure?');
var cual = this;
if (msg == false) {
$('#main-category3').attr("checked",true);
// It's check to new value and check to 3rd radio, but I want to check only 3rd radio.
}
});
</script>
我为你的代码创建了一个plunk并进行了修正