jQuery on click将class添加到div

时间:2016-10-01 22:46:25

标签: javascript jquery css

在我的on点击功能中,如何才能使我的div #complete-tick的css类为display:block;

代码:

 $('[data-popup-complete]').on('click', function(e)  {
    var targeted_popup_class = jQuery(this).attr('data-popup-complete');
    $('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
    $('[data-popup="' + targeted_popup_class + '"]').css({ display: "block" });

    e.preventDefault();
});

1 个答案:

答案 0 :(得分:1)

试试这个:

 $('[data-popup-complete]').on('click', function(e)  {
var targeted_popup_class = jQuery(this).attr('data-popup-complete');
$('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
$('[data-popup="' + targeted_popup_class + '"]').css('display', 'block');

e.preventDefault();

});