var self = $(this) //button , content = $('.content'); $('element_to_pop_up').bPopup({ onOpen: function() { content.html(self.data('bpopup') || ''); }, onClose: function() { content.empty(); } });