Bootstrap alert messages with one Jquery function

Today i will show you how to use one Jquery function to show all bootstrap messages in whole application you don’t have to copy paste the whole bootstrap message structure just call the function with parameter.

 function showalert(message,alerttype) {
      if (typeof(message)==='undefined') message = "message not found";
    if (typeof(alerttype)==='undefined') alerttype = "info";
 
    $('.container').append('<div class="alert alert-'+alerttype +'">×'+message+'</div>')
}

Demo

6 thoughts on “Bootstrap alert messages with one Jquery function

  1. Floy

    My brother suggested I would possibly like this web site.
    He was entirely right. This submit truly made my day.
    You cann’t consider just how much time I had spent for this info!

    Thank you!

  2. Maybelle

    Thanks for the marvelous posting! I actually enjoyed reading it, you’re a
    great author. I will always bookmark your blog and will come
    back sometime soon. I want to encourage one to continue your great posts, have a
    nice afternoon!

Leave a Reply

Your email address will not be published. Required fields are marked *