jquery編寫彈出信息提示條并延時滑出動畫實現(xiàn)示例
更新時間:2023年08月06日 11:18:46 作者:TANKING
這篇文章主要為大家介紹了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)容,更多關于jquery彈出提示條延時滑出動畫的資料請關注腳本之家其它相關文章!
相關文章
JQuery中兩個ul標簽的li互相移動實現(xiàn)方法
這篇文章主要介紹了JQuery中兩個ul標簽的li互相移動實現(xiàn)方法,可實現(xiàn)ul標簽中l(wèi)i標簽內(nèi)容相互替換的技巧,涉及jQuery操作頁面元素的相關技巧,需要的朋友可以參考下2015-05-05
jquery使用iscorll實現(xiàn)上拉、下拉加載刷新
這篇文章主要為大家詳細介紹了jquery使用iscorll實現(xiàn)上拉、下拉加載刷新的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10
jQuery對象數(shù)據(jù)緩存Cache原理及jQuery.data方法區(qū)別介紹
jQuery.data(..)來實現(xiàn)數(shù)據(jù)緩存,但有兩個用戶經(jīng)常使用的data([key],[value])和jQuery.data(element,[key],[value]),接下來為大家介紹下他們的區(qū)別,感興趣的朋友可以參考下哈2013-04-04
jQuery-1.9.1源碼分析系列(十一)DOM操作續(xù)之克隆節(jié)點
這篇文章主要介紹了jQuery-1.9.1源碼分析系列(十一)DOM操作續(xù)之克隆節(jié)點的相關資料,需要的朋友可以參考下2015-12-12
jQuery實現(xiàn)批量判斷表單中文本框非空的方法(2種方法)
這篇文章主要介紹了jQuery實現(xiàn)批量判斷表單中文本框非空的方法,實例分析了2種實現(xiàn)判定非空的技巧,涉及jQuery頁面元素遍歷的相關技巧,需要的朋友可以參考下2015-12-12

