jquery编写弹出信息提示条并延时滑出动画实现示例
更新时间:2023年08月06日 11:18:46 作者:TANKING
这篇文章主要为大家介绍了jquery编写弹出信息提示条并延时滑出动画实现示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
摘要
平时编写一些简单的网站,又不想添加任何的组建和外部库,但是需要一些弹窗或者弹出信息提示条,可以自己编写一个简单的小组件。
简单的小组件
<!DOCTYPE html>
<html>
<head>
<title>提示条示例</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
*{
padding: 0;
margin: 0;
}
body{
background: #eee;
}
button{
padding: 6px 20px;
}
#app{
width: 300px;
margin:20px auto;
}
.notification-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.notification {
background: #fff;
color: #333;
width: 250px;
height: 70px;
line-height: 70px;
text-indent: 15px;
border-radius: 10px;
display: block;
pointer-events: auto;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div id="app">
<!-- 创建按钮 -->
<button onclick="createNotification()">创建</button>
<!-- 提示条容器 -->
<div id="notification-container"></div>
</div>
<script>
// 计数
let notificationCount = 0;
// 创建提示条
function createNotification() {
// 增加提示条
notificationCount++;
const notificationId = `notification-${notificationCount}`;
const notification = $(
`<div class="notification" id="${notificationId}">提示条 ${notificationCount}</div>`
);
// 添加
$("#notification-container").append(notification);
// 延时隐藏+动画
setTimeout(function() {
$(`#${notificationId}`).slideUp(500, function() {
$(this).remove();
});
}, 2000);
}
</script>
</body>
</html>演示

以上就是jquery编写弹出信息提示条并延时滑出动画实现示例的详细内容,更多关于jquery弹出提示条延时滑出动画的资料请关注脚本之家其它相关文章!
相关文章
jquery.autocomplete修改实现键盘上下键自动填充示例
根据需求要实现通过键盘上下移动,获得联想菜单中的值,如同google baidu的查询功能,下面的代码是自己手写的,喜欢的朋友可以尝试操作下2013-11-11
JQuery报错Uncaught TypeError: Illegal invocation的处理方法
这篇文章主要介绍了JQuery报错"Uncaught TypeError: Illegal invocation"的处理方法,需要的朋友可以参考下2015-03-03
TimergliderJS 一个基于jQuery的时间轴插件
Timeglider JS是一个由javascript支持缩放,数据驱动的时间轴组件。非常适合显示项目历史,项目计划及其其它需要显示历史的项目2011-12-12
jQuery Timelinr实现垂直水平时间轴插件(附源码下载)
jquery.timelinr.js是一款效果非常炫酷的jQuery时间轴插件。下面脚本之家小编给大家介绍jQuery Timelinr实现垂直水平时间轴插件,需要的朋友参考下2016-02-02


最新评论