twitter-bootstrap Bootstrap 可关闭警报不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40224834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 00:21:27  来源:igfitidea点击:

Bootstrap dismissible alert not working

javascripttwitter-bootstrap

提问by Dragotic

I have been working out this bug for an hour now and can't seem to find any solution to it! I'm using bootstrap and i have a dismissible alert but when i click on the x to dismiss nothing happens.

我已经解决这个错误一个小时了,似乎找不到任何解决方案!我正在使用引导程序,我有一个可关闭的警报,但是当我单击 x 关闭时,什么也没有发生。

Here's my div

这是我的 div

<div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>Warning!</strong> Still on beta stage.
</div>

And here is my footer where i include the js files

这是我的页脚,我在其中包含了 js 文件

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

回答by Araz Shamsaddinlouy

<div class="alert alert-warning alert-dismissible" role="alert">
  <span type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></span>
  <strong>Warning!</strong> Still on beta stage.
</div>

回答by Md.Shahjalal

try using this function

尝试使用此功能

$('.close').click(function(){
     $(".test").css("display", "none");

or

或者

  $('.test').hide();

});

});

and declare a class in span tag

并在span标签中声明一个类

<strong class="test">Warning!</strong> Still on beta stage.

should be work

应该工作