简体   繁体   English

Bootstrap Alert-dismissible未在Alert div中显示

[英]Bootstrap alert-dismissible not showing in alert div

Here is my fiddle where I am trying to overlay a bootstrap alert on a bootstrap well on a click event, but the 'alert-dismissible' close box isn't showing! 这是我的小提琴 ,在这里我试图在单击事件上很好地在引导程序上叠加引导程序警报,但是没有显示“警报可禁用”关闭框! How can I get this to show and how do I hide the alert message when the alert-dismissible 'x' is clicked? 单击警报可禁用的“ x”后,如何显示该消息以及如何隐藏警报消息?

 $('.well').on('click', function() { $('.alert').show(); $('.alert').addcss('z-index: 1'); //.addClass('position: absolute'); }) 
 .well, .alert { position: absolute; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="well">Text Inside A Well</div> <div style="display: none" class="alert alert-success alert-dismissible">Test</Div> 

1.you missed the below HTML in alert div . 1.您错过了警报div的以下HTML。

<button type="button" class="close" data-dismiss="alert" aria-label="Close">
  <span aria-hidden="true">&times;</span>
</button>

2. addcss is not function. 2. addcss不起作用。 It should be css 应该是css

Demo 演示

3.The close button in above fiddle removes the alert div from DOM. 3.小提琴上方的关闭按钮可将alert div从DOM中删除。 If you want reuse the div then check this fiddle 如果要重用div请检查此小提琴

The following code works for me without javascript / jQuery : 以下代码在没有javascript / jQuery情况下对我有效:

<div class="well">Text Inside A Well
<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Test</div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM