var logger; (function (window) { logger = function (el, clearText) { var $el = $(el); addContent($el); addClearButton(clearText, $el); $('.logger--clear', $el).on('click', clear.bind('', $el)); return function(text) { var count = $('p', $el).length, $content = $('.logger--content', $el); $content.append('

' + ++count + '. ' + text + '

').scrollTop(100000) } }; function addClearButton (text, el) { el.append('' + text + '') } function addContent (el) { el.html('
') } function clear (el) { $('.logger--content', el).html(''); } })(window);