zoukankan      html  css  js  c++  java
  • jquery通过live绑定toggle事件

    $("a[name=reply]").live("click",function(){
                $(this).toggle(
                    function () {
                        var $comments = $('#microBlogReplyContainer_' + $(this).attr("value"));
                        $comments.load($comments.attr("value"));
                        $("#ListComments_" + $(this).attr("value")).show();
                        var count = $(this).text().replace(/[^0-9]/ig, "");
                        if (!count) count = 0;
                        $(this).text('收起评论(' + count + ')');
                    },
                    function () {
                        var $comments = $('#microBlogReplyContainer_' + $(this).attr("value"));
                        $("#ListComments_" + $(this).attr("value")).hide();
                        var count = $(this).text().replace(/[^0-9]/ig, "");
                        if (!count) count = 0;
                        $(this).text('评论(' + count + ')');
                    }
                ).trigger('click');
            });
    直接拿示例代码:
    $('.comBtn').live("click",function(){
     $(this).toggle(function(){ $(this).parent().parent().next('.msd_tipbox').show(); }, 
     function(){ $(this).parent().parent().next('.msd_tipbox').hide(); }).trigger('click');; } );

    说明:通过click事件绑定.再用 trigger('click')触发.防止点击第一次无效

  • 相关阅读:
    php关联Apache和nginx
    /etc/profile
    snmp配置
    snmpwalk
    redis主从
    redis安装
    计算真实可用内存
    分类样本不均
    pandas apply 添加进度条
    linux 单次定时任务
  • 原文地址:https://www.cnblogs.com/tofight/p/3230238.html
Copyright © 2011-2022 走看看