【问题标题】:On click show closed bootstrap alert box [duplicate]单击显示关闭的引导程序警报框[重复]
【发布时间】:2018-02-23 20:18:34
【问题描述】:

我为此使用Bootstrap。 当我关闭绿色文本时,我希望能够在单击按钮时再次显示,这怎么可能?

function ShowThat(){
$("#Content").show();
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<h4>Pres x to close the green label and press the button to show that again</h4>

<div id="Content" class="alert alert-success fade in alert-dismissible show" style="margin-top:18px;"> 
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true" style="font-size:20px">×</span>
</button> <strong>Success!</strong> This alert box indicates a successful or positive action.
</div>

<button onclick="ShowThat()" type="button" class="btn btn-dark">Show that again</button>

【问题讨论】:

    标签: javascript jquery html twitter-bootstrap bootstrap-4


    【解决方案1】:

    只需在您的按钮上使用onclick="$('#Content').hide()" 而不是data-dismiss="alert"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      • 2020-12-07
      • 1970-01-01
      • 2018-04-06
      • 2020-07-28
      • 1970-01-01
      • 2018-04-09
      相关资源
      最近更新 更多