基本单选框
<div class="adv_filter">
<li>
<input type="radio" name="letter_type" data-custom="Text" value="0"> Text</li>
</li>
<li>
<input type="radio" name="letter_type" data-custom="Text" value="0"> Text</li>
</li>
</div>
iCheck转换
<!-- iCheck output format
<div class="adv_filter">
<li>
<div class="iradio_square-orange checked" aria-checked="true" aria-disabled="false" style="position: relative;"><input type="radio" name="letter_type" data-custom="Text" value="0" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div> Text</li>
<li>
<div class="iradio_square-orange" aria-checked="false" aria-disabled="false" style="position: relative;"><input type="radio" name="letter_type" data-custom="Text" value="0" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div> Text</li>
</div> -->
正如您所看到的,checked 被附加到 div 上。
$(document).ready(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-orange',
radioClass: 'iradio_square-orange',
increaseArea: '20%' // optional
});
$("li").on("click", "input", function () {
var val = $(this).val();
//updateDataGrid(val);
alert(val);
});
});
问题和描述
在添加icheck插件之前,提供的javascript代码运行正常, 我想知道如何在icheck插件中获得相同的结果。简单来说,当单选按钮被点击时,它会将值存储在变量中,稍后将其传递给其他函数。
在线示例: http://jsfiddle.net/9ypwjvt4/
iCheck插件:http://fronteed.com/iCheck/