Skip to content

Instantly share code, notes, and snippets.

@mayoz
Last active December 18, 2015 11:49
Show Gist options
  • Save mayoz/5778012 to your computer and use it in GitHub Desktop.
Save mayoz/5778012 to your computer and use it in GitHub Desktop.
/*!
* toggleHtml
* $(element).toggleHtml( [html] );
*
* mit license. sercan cakir. 2012.
*/
$(function () {
$.fn.toggleHtml = function (html) {
var string = this.attr('data-toggle-html');
if (typeof attr == 'undefined' || attr == '') {
if (typeof html != 'undefined') {
string = html;
}
}
/* -- toggle html */
if (typeof string != 'undefined') {
var val = this.html();
this.html(string).attr('data-toggle-html', val);
}
/* -- for chaining */
return this;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment