Bootstrap警报不会显示

时间:2015-04-04 09:46:57

标签: twitter-bootstrap twitter-bootstrap-3 twitter-bootstrap-2

我已经将一个页面从BS2转换为BS3,我无法获得在diaglog上显示的警报。我把它缩小到一个简单的例子。我必须遗漏一些基本而明显的东西!

<div class="alert alert-danger hide" id="form-error">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">
        &times;
    </button>
</div>


<a href="#" class="btn btn-primary btn-large" type="button" onclick="mysavefunction()" id="trev">Press me</a>

保存看起来像这样

$('#form-error').html("<p>error message").show(); 

http://jsfiddle.net/GrimRob/v5sqcrLr/21/

1 个答案:

答案 0 :(得分:1)

我猜show()不起作用,因为类hide没有被这个函数删除,所以我宁愿攻击hide类:

$('#trev').click(function () {
    $('#form-error').html("<p>error message</p>").toggleClass('hide');
});

这会导致显示您的表单错误。

相关问题