javascript - 创建弹出过渡 Jquery
问题描述
我想使用 jquery 创建自定义转换弹出窗口,例如:http : //d1.internetbusinesshub.com/popup.html。
这是一个基本的弹出窗口,会在屏幕上不断出现和消失。
上面的弹出窗口是使用 jqueryMobile 创建的。我只想使用简单的 jquery 来达到预期的结果。
尝试使用 jQuery 和 CSS 进行转换,但没有成功。
以下是我的代码:
var i = 0;
$(document).ready(function() {
$("#popup_div").fadeIn();
setInterval('autoRefreshPopup()', 4000);
});
function autoRefreshPopup() {
i++;
if (i > 20) {
i = 1;
}
refreshContent(i);
var $element = $('#popup_div');
$("#popup_div").fadeIn();
setTimeout(function() {
$("#popup_div").fadeOut();
}, 3000);
}
function refreshContent(i) {
var msg = '';
switch (i) {
case 1:
msg = "text1";
break;
case 1:
msg = "text12";
break;
case 2:
msg = "text13";
break;
case 3:
msg = "text14";
break;
msg = "text";
}
$('#popup_content').html(msg);
}
#popup_div {
background: #00a8a9 !important;
color: #ffffff !important;
font-size: 12px !important;
font-family: Verdana !important;
font-weight: bold;
top: auto !important;
bottom: 0 !important;
left: 0 !important;
position: fixed;
width: 20%;
border-radius: 5px;
}
#popup_content {
padding: 5px 5px 5px 5px;
text-align: center;
}
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<p id="p_head">This is a paragraph. This text has no alignment specified.</p>
<div align="center" style="border:1px solid red; height:800px;">
This is some text in a div element!
</div>
<p>This is a paragraph. This text has no alignment specified.</p>
<div id="popup_div">
<p id="popup_content">text1</p>
</div>
</body>
解决方案
推荐阅读
- ruby-on-rails - action_text - 启用/禁用不同字段中的附件
- python - 在新版 pandas 中改造 pandas.Dataframe.ix
- python - 用于在 unix 中自动下载 jnlp 文件的 Firefox 配置文件设置
- snowflake-cloud-data-platform - Snowflake ODBC 驱动程序支持多字节(非 ascii 字符串)?
- python - 在图中,按边名访问节点连接
- c# - System.Runtime.InteropServices.SEHException - 在 OleDb 连接中使用 C#
- scala - 使用 spark/scala 从 HDFS 目录中获取所有 csv 文件名
- python - 绘制波函数:TypeError:只有大小为 1 的数组可以转换为 Python 标量
- sql - 如何选择与固定时间范围(B)重叠的时间范围(A),其中A的开始时间或结束时间超出SQL Server中B的范围
- symfony - symfony 错误处理程序的 prod 环境中缺少供应商资产