js:

var Persen = {
timeUptopBar:function(fun)
{
var obj = $('.top-alert');
obj.fadeOut(1500,function () {
if(fun && typeof(fun) != 'undefined')
{
eval(fun);
}
});
return false;
},
alertNavtopBar:function (msg, alerttype, fun)
{
if(typeof(fun) == 'undefined')
{
fun = '';
}
var obj = $('.top-alert');
var btn = $('.top-alert button');
obj.removeClass('alert-success alert-warning alert-danger');

obj.addClass('alert-'+alerttype);
$('#navbar-msg').html(msg);
obj.fadeIn(1000);
setTimeout(function(){
Persen.timeUptopBar(fun);
},3000);

btn.click(function(){
Persen.timeUptopBar(fun);
});
},

html:

<!-- 错误、成功提示 STA-->
<div class="alert alert-dismissible navbar-fixed-top top-alert alert-success" role="alert" style="min-height: 50px; height: 50px; display: none; ">
<div class="container">
<button type="button" class="close"><span aria-hidden="true">×</span></button>
<div id="navbar-msg" style="text-align: center"></div>
</div>
</div>

引用举例:


Persen.alertFail(msg);
Persen.alertSuccess(msg);

$('html,body').animate({scrollTop: '0px'}, 800); 滚动条滑动