我已经通过这种方式在 Twitter Bootstrap 中创建了一个警报
HTML:
<div id='alert' class='hide'></div>
JS:
function showAlert(message) {
$('#alert').html("<div class='alert alert-error'>"+message+"</div>");
$('#alert').show();
}
showAlert('Please have a look at yourself.');
$('#alert').removeClass('alert-error');
$('#alert').addClass('alert-info');
但是最后两行javascript好像没有什么效果,谁能帮我看看?
已创建 jsfiddle here .
更新 我对自己的代码做了一些改动,让它更容易使用,我更喜欢这种方式
HTML:
<div id='alert' class='hide'></div>
JS:
function showAlert(message, alertType) {
$('#alert').html("<div class='alert alert-"+alertType+"'>"+message+"</div>");
$('#alert').show();
}
showAlert('Please have a look at yourself.', 'success');
新的 jsfiddle here
最佳答案
$('#alert div').removeClass('alert-error');
$('#alert div').addClass('alert-info');
关于javascript - Twitter Bootstrap 警报更改类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18378920/