我的代碼是假設使3個不同的div一次一個淡入淡出,但由於某種原因,它凍結我的網站,我不知道問題是什麼或從哪裏開始修理它。一些jquery代碼導致我的網站凍結
function randomString(length) {
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
var str = '';
for (var i = 0; i < length; i++) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
var rnd = randomString(8);
jQuery(function($) {
$(".rnd").replaceWith(rnd);
$(".example").hide().each(function(i,e){
$(e).before($('<a class="show-code" href="#">Show code »</a>').
click(function(ev) {
$(e).slideToggle();
$(this).hide();
ev.preventDefault();
}));
});
});
jQuery(function(jQuery){
jQuery("#userandquery").tweet({
count: 1,
query: "from:groovetheglobe http",
loading_text: "searching twitter..."
});
jQuery("#userandquery2").tweet({
count: 2,
query: "from:groovetheglobe http",
loading_text: "searching twitter..."
});
jQuery("#userandquery3").tweet({
count: 3,
query: "from:groovetheglobe http",
loading_text: "searching twitter..."
});
});
function pulse_hide1(){
jQuery("#userandquery").fadeOut(300);
jQuery("#userandquery-bottom").fadeOut(300);
}
function pulse_hide2(){
jQuery("#userandquery2").fadeOut(300);
jQuery("#userandquery2-bottom").fadeOut(300);
}
function pulse_hide3(){
jQuery("#userandquery3").fadeOut(300);
jQuery("#userandquery3-bottom").fadeOut(300);
}
function pulse_show1(){
jQuery("#userandquery").fadeIn(300);
jQuery("#userandquery-bottom").fadeIn(300);
}
function pulse_show2(){
jQuery("#userandquery2").fadeIn(300);
jQuery("#userandquery2-bottom").fadeIn(300);
}
function pulse_show3(){
jQuery("#userandquery3").fadeIn(300);
jQuery("#userandquery3-bottom").fadeIn(300);
}
function call_pulse_hide(){
setTimeout("pulse_hide1()",1000);
setTimeout("pulse_hide2()",3000);
setTimeout("pulse_hide3()",3000);
}
function call_pulse_show(){
pulse_show1();
setTimeout("pulse_show2()",3000);
setTimeout("pulse_show3()",3000);
}
function pulse_function(){
while(true){
call_pulse_hide();
call_pulse_show();
}
}
jQuery(document).ready(function(){
/*jQuery('#fadeout').fadeOut(300);
jQuery('#fadein').delay(400).fadeIn(300);*/
pulse_function();
//alert("document done");
});
任何機會,我們可以得到一個小提琴或一些HTML去呢?快速猜測會有一個錯誤導致javascript停止運行。 –