当我点击它时打开多个重播框

时间:2015-06-03 13:26:28

标签: php jquery ajax

朋友我发表了评论和重播框,但重播中存在问题    当我点击重播按钮打开它打开多个重播框。顶部重播框工作正常,底部重播框不正常工作。我尝试解决这个问题,但是,我无法做到这一点   请帮我解决一下。

$(function() {

    //alert(event.timeStamp);
    $('.new-rep-bt').click(function(event) {
        var idval = $(this).attr('id');
        alert(idval);
        $(this).hide();
        $('.new-rep-bt').hide();
        $('.new-rep-cnt').show();
        $('#name-rep').focus();

    });

    /* when start writing the comment activate the "add" button */
    $('.the-new-rep').bind('input propertychange', function() {
        $(".bt-add-rep").css({
            opacity: 0.6
        });
        var checklength = $(this).val().length;
        if (checklength) {
            $(".bt-add-rep").css({
                opacity: 1
            });
        }
    });

    /* on clic  on the cancel button */
    $('.bt-cancel-rep').click(function() {
        $('.the-new-rep').val('');
        $('.new-rep-cnt').fadeOut('fast', function() {
            $('.new-rep-bt').fadeIn('fast');
        });
    });

    // on post comment click 
    $('.bt-add-rep').click(function() {
        var hiddenid = $('#hiddenid');
        var therep = $('.the-new-rep');
        var therepName = $('#name-rep');
        var therepMail = $('#mail-rep');

        if (!therep.val()) {
            alert('You need to write a comment!');

        } else {
            $.ajax({
                type: "POST",
                url: "add-comment.php",
                data: 'action=add-rep&id_replay=' + <? php echo $id_replay; ?> +'&hiddenid=' + hiddenid.val() + '&repname=' + therepName.val() + '&repemail=' + therepMail.val() + '&repcomment=' + therep.val(),
                success: function(html) {
                    therep.val('');
                    therepMail.val('');
                    therepName.val('');
                    $('.new-rep-cnt').hide('fast', function() {
                        $('.new-rep-bt').show('fast');
                        $('.new-rep-bt').before(html);
                    })
                }
            });
        }
    });

});

0 个答案:

没有答案