jQuery弹窗广告代码通常用于在网页上显示弹出式的广告窗口。以下是一个简单的示例,展示了如何使用jQuery创建一个基本的弹窗广告:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery Popup Ad</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
#popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: white;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
z-index: 1000;
}
#overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 999;
}
</style>
</head>
<body>
<div id="overlay"></div>
<div id="popup">
<p>This is a popup ad!</p>
<button id="closePopup">Close</button>
</div>
<script>
$(document).ready(function() {
// Show the popup after 3 seconds
setTimeout(function() {
$('#overlay, #popup').fadeIn();
}, 3000);
// Close the popup when the close button is clicked
$('#closePopup').click(function() {
$('#overlay, #popup').fadeOut();
});
// Close the popup when clicking outside of it
$('#overlay').click(function(event) {
if (event.target.id === 'overlay') {
$('#overlay, #popup').fadeOut();
}
});
});
</script>
</body>
</html>
希望这些信息对你有所帮助!如果有更多具体问题,欢迎继续提问。
领取专属 10元无门槛券
手把手带您无忧上云