Dynamically create Bootstrap alerts box through JavaScript

前端 未结 10 913
有刺的猬
有刺的猬 2020-12-13 12:20

I\'m using Bootstrap 2.0 for my project and I would like to dynamically add Bootstrap alert box in my page (http://twitter.github.com/bootstrap/javascript.html#alerts). I wa

10条回答
  •  萌比男神i
    2020-12-13 12:56

    Found this today, made a few tweaks and combined the features of the other answers while updating it to bootstrap 3.x. NB: This answer requires jQuery.

    In html:

    In JS:

    Then you can invoke this either as:

    bootstrap_alert('#form_errors', 'This message will fade out in 1 second', 1000)
    bootstrap_alert('#form_errors', 'User must dismiss this message manually')
    

提交回复
热议问题