js中弹框有那些,提示框、请求成功弹窗、请求失败弹框等

我这里写的是个人推荐仅供参考:

效果图:

代码实现

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.6.3.js"></script>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.hinte {
				width: 320px;
				height: 50px;
				text-align: center;
				line-height: 50px;
				background-color:#F0F9EB ;
				color:#6BC440;
				border-radius: 5px;
				position: fixed;
				top: 20px;
				left: calc(50% - 160px);
				z-index: 999;
				display: none;
			}
			/* 失败 */
			.hintes {
				width: 320px;
				height: 50px;
				text-align: center;
				line-height: 50px;
				background-color:#FEF0F0;
				color: red; 
				border-radius: 5px;
				position: fixed;
				top: 20px;
				left: calc(50% - 160px);
				z-index: 999;
				display: none;
			}
			/* 提示 */
			.hinted {
				width: 320px;
				height: 50px;
				text-align: center;
				line-height: 50px;
				background-color: #FDF6EC;
				color: #ffe042;
				border-radius: 5px;
				position: fixed;
				top: 20px;
				left: calc(50% - 160px);
				z-index: 999;
				display: none;
			}
			
		</style>
	</head>
	<body>
		<div class="box">
			<button onclick="detrusion()">成功弹框</button>
			<button onclick="detrusions()">失败弹框</button>
			<button  onclick="detrusionss()">提示弹框</button>
			<!-- 成功弹框 -->
			<div class="hinte">成功弹框</div>
			<!-- 失败弹框 -->
			<div class="hintes">失败弹框</div>
			<!-- 提示弹框 -->
			<div class="hinted">提示弹框</div>
			
			<script>
				function detrusion() {
					$(".hinte").slideToggle().text('成功弹框').fadeIn();
					setTimeout(() => {
						$(".hinte").slideToggle();
						
					}, 2000)
					
					
				}
				function detrusions() {
					$(".hintes").slideToggle().text('失败弹框').fadeIn();
					setTimeout(() => {
						$(".hintes").slideToggle();
						
					}, 2000)
					
				}
				function detrusionss() {
					$(".hinted").slideToggle().text('提示弹框').fadeIn();
					setTimeout(() => {
						$(".hinted").slideToggle();
					
					}, 2000)
					
				}
			</script>
		</div>
	</body>
</html>

以上内容仅供大家参考,希望可以帮到大家;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值