我99%肯定我在这里遗漏了一些非常明显的东西。单击该按钮应使带有.progress
类的div可见。不是。
function func() {
$('.progress').show();
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="progress d-none">
No longer hidden!
</div>
<button onclick="func()">
click me
</button>
答案 0 :(得分:2)
@jsnfwlr答案的另一种替代方法是从项目中删除类 d-none ,如下所示:
max
答案 1 :(得分:1)
如果不确定如何通过Bootstrap的d-none
或常规display: none
隐藏元素,但是无论如何都需要使其可见,只需使用以下代码:
$(el).removeClass("d-none").show();
答案 2 :(得分:0)
jquery的显示与bootstrap的d-none不兼容。您可以使用Collapse-https://getbootstrap.com/docs/4.1/components/collapse/-