如何在jQuery中处理两个进程
how to handle two processes in jQuery
下面的代码只处理包含setInterval的脚本,而其他脚本是不可访问的。
我应该如何处理这两个脚本?
<html>
<head>
<title>Top News</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery/jquery-1.5.2.js"></script>
</head>
<body>
<div class="top-new-content">
<div class="one" style="position: absolute; left: 10px; top: 10px; background:yellow;width:300px;height:100px; border: 1px #979797 solid">
<img src="image/news/img.jpg" width="100px" height="50px" />
</div>
<div class="two" style="position: absolute; left: 10px; top: 10px;background:yellow;width:300px;height:100px; border: 1px #979797 solid">
two two two two two two two ...
</div>
<div class="three" style="position: absolute; left: 10px; top: 10px; background:yellow;width:300px;height:100px; border: 1px #979797 solid">
three three three three three ...
</div>
</div>
<div class="top-news-category" style="position: absolute; left: 10px; top: 111px; border: 1px #979797 solid; border-top: none; background-color: yellow">
<span id="a">One |</span>
<span id="b">Two |</span>
<span id="c">Three</span>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
setInterval(function() {
$('div.one').fadeIn(1000);
$('div.two').fadeOut(1000);
$('div.three').fadeOut(1000);
$("*").delay(3000);
$('div.two').fadeIn(1000);
$('div.one').fadeOut(1000);
$('div.three').fadeOut(1000);
$("*").delay(3000);
$('div.three').fadeIn(1000);
$('div.one').fadeOut(1000);
$('div.two').fadeOut(1000);
$("*").delay(3000);
}, 0);
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".top-news-category #a").click(function(){
$("div.one").fadeIn("slow", "linear");
$("div.two").fadeOut("slow", "linear");
$("div.three").fadeOut("slow", "linear");
});
$(".top-news-category #b").click(function(){
alert("TWO");
$("div.one").fadeOut("slow", "linear");
$("div.three").fadeOut("slow", "linear");
$("div.two").fadeIn("slow", "linear");
});
$(".top-news-category #c").click(function(){
$("div.one").fadeOut("slow", "linear");
$("div.three").fadeOut("slow", "linear");
$("div.three").fadeIn("slow", "linear");
});
});
</script>
hi ammar我已经通过答案检查进行了编辑。
setInterval(function() {
$('div.one').fadeIn(1500);
$('div.two').fadeOut(1500);
$('div.three').fadeOut(1500);
$("*").delay(15000);
$('div.two').fadeIn(1500);
$('div.one').fadeOut(1500);
$('div.three').fadeOut(1500);
$("*").delay(15000);
$('div.three').fadeIn(1500);
$('div.one').fadeOut(1500);
$('div.two').fadeOut(1500);
$("*").delay(15000);
}, 100000);
当您研究setInterval方法描述时,第一个参数是函数,第二个参数是需要一次又一次执行函数的持续时间(以毫秒为单位(。先前您已将其指定为0,这导致了问题。希望这对你有帮助,。。。。
问题是你没有在document.ready上运行你的第一个代码段。试着把它包装在$(document).ready(...
上,它应该可以正常工作。
脚本标记需要在结束标记之前位于内部。此外,我建议用"documentready"来包装这两个脚本标记。
JQuery中使用文档就绪的最干净/最短方式。
$(function() {
...my code here...
});
相关文章:
- JQuery合并了keyup和focusout两个函数
- 如何使用 node.js 比较两个 json 数组
- 为复选框javascript指定两个值
- 用每小时的差值填充数组/列表-从下拉列表中给定两个时间值
- 单击时切换两个图像
- 我可以'我似乎不知道如何修复javascript中的两个lint.有人能帮我理解吗
- 基于两个条件退出While循环
- 如何在这里将两个值最低的数字相加
- 组合两个javascript函数
- 如何使用offer/answer交换来自两个对等连接的流
- jsf中两个字符串的颜色代码差异
- 加载两个具有相同父密钥名称的json文件
- 在Qualtrics中,介绍如何动态连接两个滑块
- 访问$.ajax()函数中的两个不同数组
- 在一个node.js进程中组合两个主循环
- 从单节点进程提供两个https主机名&港口城市
- 如何确保两个或多个节点进程(child_process)中的逻辑同步
- 用javascript同步两个进程
- Electron中两个渲染器进程之间的通信
- 如何在jQuery中处理两个进程