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')触发.防止点击第一次无效

  • 相关阅读:
    内网Windows Server时间自动同步
    处理sqlserver数据
    virtualenv使用
    vue过渡动画效果
    vue视图
    vue组件
    Vue实例
    vue介绍
    Bootstrap布局
    Bootstrap组件
  • 原文地址:https://www.cnblogs.com/tofight/p/3230238.html
Copyright © 2011-2022 走看看