使用Bootstrap 3,我想在稍后显示的页面上有一个元素,以响应用户单击按钮。例:
<div id="search_results">
... gets populated from ajax data later ...
</div>
<button id="search_button" type="button" class="btn btn-primary pull-right">Search</button>
<script>
$('#search_button').click(function() {
// ... do the call to search
// and in the callback:
$('#search_results').show();
});
</script>
search_results div应该最初隐藏。是否有一些正常/最佳实践方式使用bootstrap执行此操作?
是的,我确实知道我可以在search_results上放置style =“display:none”,但这是最好的方法吗?拥有一种语义上意味着“最初隐藏”的风格似乎要好一些。 (注意:隐藏或隐藏类不会这样做!重要和show(),toggle()等使用不覆盖它们的内联样式,即设置“隐藏”,因为类使其无法显示来自jQuery。)