Skip to content

Instantly share code, notes, and snippets.

@burnoutprojects
Forked from afshinm/bootstrap.messagebox.js
Created November 22, 2017 03:41
Show Gist options
  • Save burnoutprojects/7eac11ed9d5296cbd71a6a7ab440d3fd to your computer and use it in GitHub Desktop.
Save burnoutprojects/7eac11ed9d5296cbd71a6a7ab440d3fd to your computer and use it in GitHub Desktop.
Twitter Bootstrap Message Box Plugin
(function ($) {
/* Twitter Bootstrap Message Helper
** Usage: Just select an element with `alert` class and then pass this object for options.
** Example: $("#messagebox").message({text: "Hello world!", type: "error"});
** Author: Afshin Mehrabani <afshin.meh@gmail.com>
** Date: Monday, 08 October 2012
*/
$.fn.message = function(options) {
//remove all previous bootstrap alert box classes
this[0].className = this[0].className.replace(/alert-(success|error|warning|info)/g , '');
this.html(options.text).addClass("alert-" + (options.type || "warning"));
this.show();
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment