首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery each 内部的延时这样写可有用啊解决方法

2012-03-29 
jquery each 内部的延时这样写可有用啊?function postmessage(){var delayTime []$.each(arr,function(

jquery each 内部的延时这样写可有用啊?
function postmessage(){
var delayTime = [];

$.each(arr,function(key,val){
//回调函数有两个参数,第一个是元素索引,第二个为当前值
delayTime[key] = setTimeout(function() {
$("#postform").attr("action",val);
$("#postform").attr("target","_blank"); 
$("#postform").submit();
},2000)

//if (key > 28) return false;

//$.post(val, $("#postform").serialize());
});
}

遍历数组,数组是n个url地址,然后向这些url提交表单

同时提交的太多了,很卡

想做个延时,怎么写啊?

[解决办法]
这样也是掩饰,延时有函数可使用,不要认为的去做一些无谓的操作

HTML code
<html><head><script src="http://code.jquery.com/jquery-latest.js"></script><script>function show(){ alert("show!!");}$(function(){  $('#mydiv').mouseover(function(){  t = setTimeout("show()",2000); }).mouseout(function(){  clearTimeout(t); });});</script></head><body> <span id="mydiv">我是菜单</span></body> 

热点排行