仅在Chrome中,asp复选框上不会触发onchange事件 [英] onchange event is not fire on asp checkbox in chrome only

查看:63
本文介绍了仅在Chrome中,asp复选框上不会触发onchange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不适用于Chrome浏览器

This doesn't work for me in chrome

<asp:CheckBox ID="chkFullReIndex" runat="server" ClientIDMode="Static" onchange="funCalled();" />

<script>
     function funCalled() {
        if ($('#chkFullReIndex')[0].checked) {
            alert('check box checked')
        }
        else {
           alert('check box not checked')
        }
    }
</script>

这在Firefox(21.0)中工作得很好,但在chrome(版本27.0.1453.94 m)中却无法工作,而在同一操作系统上却没有任何控制台错误

This is working perfectly fine in Firefox(21.0) but not working in chrome(Version 27.0.1453.94 m)am not getting any console error for the same

任何想法都相同

推荐答案

尝试使用 onclick 事件之类的

<asp:CheckBox runat="server" ID="chkPostback" Text="Check me" onclick="javascript:funCalled(this)"
        ClientIDMode="Static" />

脚本

function funCalled(obj) {
    if (obj.checked) {
        alert('check box checked')
    } else {
        alert('check box not checked')
    }
}

检查

这篇关于仅在Chrome中,asp复选框上不会触发onchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆