点击回复弹出回复框名称变成取消回复的事件

        //点击回复事件
        $(".reply-text").on('click', function() {
            var currentEle = $(this)
            var text = currentEle.text();
            currentEle.html(text === '回复' ? '取消回复' : '回复');
            //给兄弟节点的文本变成回复
            $(".reply-publish").each(function(i) {
                    $(this).siblings().find('.reply-text').text('回复')
                    $(this).remove()
                })
                // $(".reply_textarea").remove();
            if (text === '取消回复') {
                currentEle.parent().find(".reply-publish").remove()
                return
            }
            var template = "<div class='reply-publish reply_textarea'><textarea name='replyContent' id='replyContent'></textarea><div class='btn-publish'><button class='reply-fabu' >发布</button></div> </div>"
            $(this)
                .parent()
                .parent()
                .append(template);
        })

2.点击发布事件失效,原因是点击的事件在事件按钮前加载,需要把点击事件改成下面的内容

$(".list-neirou").on('click', '.reply-fabu', function() {
                console.log(1)
                if (obj === null || obj === '') {
                    layer.msg("请先登录才能回复发布的评论!!!");
                    return false;
                }
})
posted @ 2022-01-24 10:14  java璀璨小菜鸟  阅读(74)  评论(0)    收藏  举报