How to toggle a bootstrap alert on and off with button click?

前端 未结 9 1155
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 21:21

I want to display an alert box multiple times with a button click event without having to refresh the page but the alert box only shows up once. If I want to show the alert box

9条回答
  •  无人共我
    2021-01-30 21:48

    I used the following working approach based on Leiko's solution.

    $(document).ready(function(){
        $("#btnFV").click(function()
        {
            $("#alertFV").addClass("in");
        });
    
        $("#alertFV").on("close.bs.alert", function ()
        {
            $("#alertFV").removeClass("in");
            return false;
        });
    });
    

    Html body contains below alert

    
    
    
    Danger!

提交回复
热议问题