jQuery的Growl插件

jQuery的Growl插件

Growl插件

消息提醒,允许您很容易地在一个覆盖层显示反馈消息

消息会在一段时间后自动消失,不需要单击确定按钮

也可以通过移动鼠标或点击关闭按钮加快隐藏信息

引入JS

<script src="https://cdn.bootcss.com/jquery/2.0.2/jquery.min.js" type="text/javascript"></script>

<script src="https://static.runoob.com/assets/jquery/jquery.growl/javascripts/jquery.growl.js" type="text/javascript"></script>

<link href="https://static.runoob.com/assets/jquery/jquery.growl/stylesheets/jquery.growl.css" rel="stylesheet" type="text/css" />

  • 1
  • 2
  • 3

文本元素

选择需要设置的显示文本元素,把文本作为参数传递给它

$.growl({ title: "消息标题", message: "消息内容!" });

$.growl.error({ title: "错误标题", message: "错误消息内容!" });

$.growl.notice({title: "提醒标题", message: "提醒消息内容!" });

$.growl.warning({title: "警告标题", message: "警告消息内容!" });

  • 1
  • 2
  • 3
  • 4

示例代码

$(function() {

$.growl({

title: "消息标题",

message: "消息内容!"

});

$('.error').click(function(event) {

event.preventDefault();

event.stopPropagation();

return $.growl.error({

title: "错误标题",

message: "错误消息内容!"

});

});

$('.notice').click(function(event) {

event.preventDefault();

event.stopPropagation();

return $.growl.notice({

title: "提醒标题",

message: "提醒消息内容!"

});

});

return $('.warning').click(function(event) {

event.preventDefault();

event.stopPropagation();

return $.growl.warning({

title: "警告标题",

message: "警告消息内容!"

});

});

});

相关推荐