码迷,mamicode.com
首页 > 其他好文 > 详细

off("click")的使用

时间:2017-03-17 14:51:18      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:bre   remove   lte   difficult   group   offline   index   switch   file   

今天遇到一个奇怪的问题,用鼠标点击一次HTML button,但是从firebug查看,重复发送了N条请求,写alter调试,发现页面点击一次Click,被浏览器重复捕获N次!
    $("ul.list-group li").click(function () {   //改为 $("ul.list-group li").off("click").click(function () { 问题得以解决!
        //debugger;
        //alert(133333);
        $(this).addClass("active").siblings().removeClass("active");
        var loadFile = ‘‘;
        switch ($(this).attr(‘id‘))
        {
            case ‘difficultSupport‘:
                loadFile = "index.php?extendModule-difficultSupport-index-ajax";
                break;
            case ‘protectRight‘:
                loadFile = "index.php?extendModule-protectRight-index-ajax";
                break;
            case ‘venueBooking‘:
                loadFile = "index.php?extendModule-venueBooking-index-ajax";
                break;
            case ‘policyCoduct‘:
                loadFile = "index.php?extendModule-policyCoduct-index-ajax";
                break;
            case ‘legalAid‘:
                loadFile = "index.php?extendModule-legalAid-index-ajax";
                break;
            case ‘psycholConsult‘:
                loadFile = "index.php?extendModule-psycholConsult-index-ajax";
                break;
            case ‘offlineTraining‘:
                loadFile = "index.php?extendModule-protectRight-index-ajax";
                break;
            case ‘askAbout‘:
                loadFile = "index.php?extendModule-askAbout-index-ajax";
                break;
            default:
        }
        $("div #detail").load(loadFile, function (response, status, xhr) {
            $(‘div #detail‘).html(response);
        });
    });

off("click")的使用

标签:bre   remove   lte   difficult   group   offline   index   switch   file   

原文地址:http://www.cnblogs.com/yiqianer/p/6565780.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!