Jquery Own function

by Santosh Thakur

HTML

<span>click!</span>

CSS

div {
  background: #ffcc00;
  margin:5px;
  display: none;
}

span {
  background: green;
}

JavaScript

var i = 0;
$('span').click(function() {
i++;
  $(this).showTxt('<div>' + 'This is text >>> ' + i + '</div>' );
});

jQuery.fn.showTxt = function(html) {
  $(html).insertAfter('span').fadeIn();
  return this;
}