它看起来简单直接,但我无法管理简单的复选框单击。
HTML
<input type="checkbox" name="chkfront[]" class="front-checkbox">
jQuery
<script language="javascript">
$(document).ready(function () {
alert("triggered1");
$(".front-checkbox").click(function() {
alert("triggered");
});
});
但它根本不起作用,也没有显示错误。我被困住了。
当我尝试:
<a class="front-checkbox" href="javascript:void(0)">dd</a>
它正在工作..为什么它的复选框行为异常?
在检查复选框时,我发现以下内容:
<input type="checkbox" name="chkfront" class="front-checkbox" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins>
我怀疑复选框正在生成 div 并在那里触发事件。
最佳答案
我通过 icheck 文档以某种方式管理了它
$(document).ready(function () {
$('.front-checkbox').on('ifChecked', function(event){
alert('xx');
});
});
关于javascript - 事件处理复选框 - jQuery icheck 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25785519/