Search code examples
twitter-bootstraptwitter-bootstrap-3twitter-bootstrap-2

Bootstrap alert will not show


I have converted a page from BS2 to BS3 and I can't get the alert to show on a diaglog. I have shrunk it down to a simple example. I must be missing something basic and obvious!

<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>

Save looks like this

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

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


Solution

  • I guess show() doesnt work, since the class hide doesnt get removed by this function, so I'd rather attack the hide class:

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

    This results in your form-error being shown.