jquery編寫彈出信息提示條并延時滑出動畫實現(xiàn)示例
摘要
平時編寫一些簡單的網(wǎng)站,又不想添加任何的組建和外部庫,但是需要一些彈窗或者彈出信息提示條,可以自己編寫一個簡單的小組件。
簡單的小組件
<!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">
<!-- 創(chuàng)建按鈕 -->
<button onclick="createNotification()">創(chuàng)建</button>
<!-- 提示條容器 -->
<div id="notification-container"></div>
</div>
<script>
// 計數(shù)
let notificationCount = 0;
// 創(chuàng)建提示條
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編寫彈出信息提示條并延時滑出動畫實現(xiàn)示例的詳細內(nèi)容,更多關(guān)于jquery彈出提示條延時滑出動畫的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
jQuery實現(xiàn)鼠標單擊網(wǎng)頁文字后在文本框顯示的方法
這篇文章主要介紹了jQuery實現(xiàn)鼠標單擊網(wǎng)頁文字后在文本框顯示的方法,可實現(xiàn)鼠標點擊上方文字即可在下方勾選處文本框顯示對應(yīng)文字的效果,涉及jQuery鼠標事件及鏈式操作的相關(guān)技巧,需要的朋友可以參考下2015-05-05
jquery.autocomplete修改實現(xiàn)鍵盤上下鍵自動填充示例
根據(jù)需求要實現(xiàn)通過鍵盤上下移動,獲得聯(lián)想菜單中的值,如同google baidu的查詢功能,下面的代碼是自己手寫的,喜歡的朋友可以嘗試操作下2013-11-11
jQuery中設(shè)置form表單中action值的實現(xiàn)方法
下面小編就為大家?guī)硪黄猨Query中設(shè)置form表單中action值的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
JQuery報錯Uncaught TypeError: Illegal invocation的處理方法
這篇文章主要介紹了JQuery報錯"Uncaught TypeError: Illegal invocation"的處理方法,需要的朋友可以參考下2015-03-03
TimergliderJS 一個基于jQuery的時間軸插件
Timeglider JS是一個由javascript支持縮放,數(shù)據(jù)驅(qū)動的時間軸組件。非常適合顯示項目歷史,項目計劃及其其它需要顯示歷史的項目2011-12-12
jQuery Timelinr實現(xiàn)垂直水平時間軸插件(附源碼下載)
jquery.timelinr.js是一款效果非常炫酷的jQuery時間軸插件。下面腳本之家小編給大家介紹jQuery Timelinr實現(xiàn)垂直水平時間軸插件,需要的朋友參考下2016-02-02

