如何为弹出窗口添加“关闭”按钮?

如何为这个弹出窗口添加“关闭”按钮?单击Продолжить покупки时关闭。

HTML 代码:

<div id="notification"></div>

函数调用后的HTML代码:

<div id="notification"><div class="layer">&nbsp;</div><div class="addtocart_window"><div class="c"><div class="t">Товар добавлен в корзину</div><a class="btn btn-default btn-subscribe" href="/cart_items/" title="Оформить заказ">Оформить заказ</a><br><br><a class="t2 close2">Продолжить покупки</a></div></div></div>

压根不起作用。

$('#button-cart').bind('click', function() {

    $.ajax({
        url: 'index.php?route=checkout/cart/add',
        type: 'post',
        data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
        dataType: 'json',
        success: function(json) {
            $('.success, .warning, .attention, information, .error').remove();

            if (json['error']) {
                if (json['error']['option']) {
                    for (i in json['error']['option']) {
                        $('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
                    }
                }
            } 

            if (json['success']) {

                $('#notification').html('<div class="layer">&nbsp;</div><div class="addtocart_window"><div class="c"><div class="t">Товар добавлен в корзину</div><a class="btn btn-default btn-subscribe" href="/cart_items/" title="Оформить заказ">Оформить заказ</a><br><br><a class="t2 close2">Продолжить покупки</span></div></div>');

                $('.success').fadeIn('slow');

                $('html, body').animate({ scrollTop: 0 }, 'slow'); 
            }


        }
    });

$('.close2').on('click', function(){
  $('#notification').hide().empty();
});
});

It depends on what you mean by 'close' I think what you're trying to do is either hide the notification, but also empty it, as you've added the html inline on the response. I can't see the css on #notification, but I'm assuming this will work to first hide the notification window (assuming that is what the modal is) and then empty it of it's contents.

$('.close2').on('click', function(){
  $('#notification').hide().empty();
});

You can delegate the event to the closest static parent or $(document):

$('#notification').on('click', '.close2', function(){ 
     $(this).closest('#notification').empty().hide();
});

You can delegate the event to this too $(document).on('click',