 <p>Try this:</p> <pre><code> $('[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(); </code></pre> <p>});</p>