写一个页面,每隔3秒显示小广告,再过3秒自动关闭。
<head>
<meta charset="UTF-8">
<title>暖心广告</title>
<style>
img {
display: none;
}
</style>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
function showAd() {
$("#pic").fadeIn("slow", function() {
$(this).css({
"border": "1px solid #ccc",
"padding": "5px"
});
});
}
function closeAd() {
$("#pic").fadeOut(1000);
}
$(function() {
setInterval("showAd()", 1000);
setInterval("closeAd()", 3000);
});
</script>
</head>
<body>
<p><img src="img/img1.jpg" id="pic" /></p>
</body>
原文:https://www.cnblogs.com/tigerlion/p/11178783.html