我使用iCheck創建了現代單選按鈕,並且有四個選項。當用戶改變單選按鈕時,我彈出確認消息「你確定嗎?」帶iCheck的單選按鈕僅在確認返回true時更改值
如果確認返回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>
如果加上'返回FALSE'會發生什麼? –
@JamesDonnelly; add return false - >它不會發生 – punny