Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2012 09:46
  • Star 4 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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 <>
** 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"));;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment