我正在使用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>
答案 0 :(得分:0)
只需在按钮上使用onclick="$('#Content').hide()"
代替data-dismiss="alert"
。