- JScript code
$(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On mouseover Event $("ul.tabs li").mouseover(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); });
------解决方案--------------------
window.setInterval( function() {/*你的代码*/}, 1000);
------解决方案--------------------
可以的
javascript模拟sleep
- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>javascript模拟sleep http://www.ok22.org幸凡在线学习,网页设计,技术交流区,在线学习网,免费视频教程</title> </head> <body> <script> function Pause(obj,iMinSecond){ if (window.eventList==null) window.eventList=new Array(); var ind=-1; for (var i=0;i<window.eventList.length;i++){ if (window.eventList[i]==null) { window.eventList[i]=obj; ind=i; break; } } if (ind==-1){ ind=window.eventList.length; window.eventList[ind]=obj; } setTimeout("GoOn(" + ind + ")",iMinSecond); } //js继续函数 function GoOn(ind){ var obj=window.eventList[ind]; window.eventList[ind]=null; if (obj.NextStep) obj.NextStep(); else obj(); } function testJsStop(){ //调用方法 alert("1"); Pause(this,2000);//2秒钟扣执行nextstep事件。。这样就可以设置下一个方法执行的开始时间 this.NextStep=function(){ alert("2"); } } testJsStop(); </script> </body> </html>
------解决方案--------------------
不好意思,函数是这个setTimeout():
function test(){
alert($("#input1").val());
}
$(function(){
$("#input1").click(function(){
setTimeout("test()",1000);
});
});