本文主要和大家聊聊Jquery的noty弹框应用,需要的朋友可以参考下,希望能帮助到大家。
导入jar包(这边是项目的相对路径)
<script src='${ctx}/js/noty/jquery.noty.js'></script>
<script src='${ctx}/js/noty/themes/default.js'></script>
<script src='${ctx}/js/noty/layouts/topCenter.js'></script>
登录后复制
简单的例子:
if(name=="删除" || name=="登记"){
$("#noty_topCenter_layout_container").remove();
noty({
text: "您真的确定要"+name+"吗?\n\n请确认!",
type: 'alert',
dismissQueue: true,
layout:'topCenter',
theme: 'default',
buttons: [
{
addClass: 'btn btn-primary btn-sm background-blue', text: '确定', onClick: function ($noty) {
$noty.close();
formSubmit (url,sTarget);
}
},
{
addClass: 'btn btn-danger btn-sm background-red', text: '取消', onClick: function ($noty) {
$noty.close();
}
}
]
});
}else{
formSubmit (url,sTarget);
}
登录后复制
这边是一个提交跳转的按钮,
加上remoe是为了不能开多个,当你开启一个弹框的时候关闭另一个弹框;
layout: 'topCenter',这个是改变弹框位子的,要和导入的js名称相对应;
自带样式有些地方不是很好看,那么我们需要修改
那么如何加弹框呢?在jquery.noty.js中
在弹框的前面加上一个提示:jQuery prepend() 方法
样式的大小或者是css直接在网页上截取
_build: function()下
var $bar = $('<p class="noty_bar"/>').attr('id', this.options.id);
$bar.prepend('<p style="padding: 5px;
border-bottom:1px #e8e8e8 solid;
text-align: left;
border-top: 1px solid #e8e8e8;
background-color: rgb(255, 255, 255);width: 90%;margin: auto;">提示:</p>');
$bar.append(this.options.template).find('.noty_text').html(this.options.text);
登录后复制
有一条下划线,现在把它变为宽度的百分之80,居中
自带的还有一个下划线很难找,不能直接在外面的style中修改,需要在jquery.noty.js中找到
show: function()
if (self.options.timeout)
self.$bar.delay(self.options.timeout).promise().done(function() { self.close(); });
this.$bar.find('.noty_buttons').css("borderTop","1px solid rgb(220, 220, 220) ");
return this;
},
登录后复制
背景颜色横条不好看,在default中修改style: function
中间宽度太小,可以修改margin
如何修改确认,取消,按钮颜色
在创建他们的地方加上class,然后在引入jsp的页面加上style
最后的样式:
以上就是浅谈Jquery的noty弹框应用的详细内容,更多请关注php中文网其它相关文章!
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
- 上一篇:浅谈jquery中的extend函数
- 下一篇:js的内置对象详解