2014-05-30 2 views
0

я не могу изменить выход Див, я это Js, но эта нагрузка для второй DIV: [код]Javascript выцветает два окна в одном сНу идентификатор

var next = null; 
    var outer = jQuery('#wp_bannerize-2 > #banners'); 
    var current = outer.find('.box:first'); 
    current.fadeIn(); 
    function fade() { 
     if (current.next('div.box').length > 0) { 
      next = current.next('div.box'); 
     } else { 
      next = outer.find('.box:first'); 
     } 

     current.fadeOut(); 
     next.fadeIn(); 
     current = next; 
     setTimeout(fade, 1000); //5secondi 
    } 
    // start the process 
    fade(); 


    var next = null; 
    var outer = jQuery('#wp_bannerize-3 > #banners'); 
    var current = outer.find('.box:first'); 
    current.fadeIn(); 
    function fade() { 
     if (current.next('div.box').length > 0) { 
      next = current.next('div.box'); 
     } else { 
      next = outer.find('.box:first'); 
     } 

     current.fadeOut(); 
     next.fadeIn(); 
     current = next; 
     setTimeout(fade, 1000); //5secondi 
    } 
    // start the process 
    fade(); 

[/ код] Как может Я решаю это? Я думаю, что я заменил js var next и var next2. LIVE: http://jsfiddle.net/EmQmL/2/

ответ

0

Я не уверен, с какой целью вы это делаете. В коде содержится столько деклараций переменных. По этой причине он не работает. Обновите свой код, как показано ниже, он будет работать. Но я не могу сказать, что это идеальный ответ. На данный момент вы можете использовать это.

 var next1 = null; 
    var outer1 = jQuery('#wp_bannerize-2 > #banners'); 
    var current1 = outer1.find('.box:first'); 
    current1.fadeIn(); 
    function fade1() { 
     if (current1.next('div.box').length > 0) { 
      next1 = current1.next('div.box'); 
     } else { 
      next1 = outer1.find('.box:first'); 
     } 

     current1.fadeOut(); 
     next1.fadeIn(); 
     current1 = next1; 
     setTimeout(fade1, 1000); //5secondi 
    } 
    // start the process 
    fade1(); 


    var next = null; 
    var outer = jQuery('#wp_bannerize-3 > #banners'); 
    var current = outer.find('.box:first'); 
    current.fadeIn(); 
    function fade() { 
     if (current.next('div.box').length > 0) { 
      next = current.next('div.box'); 
     } else { 
      next = outer.find('.box:first'); 
     } 

     current.fadeOut(); 
     next.fadeIn(); 
     current = next; 
     setTimeout(fade, 1000); //5secondi 
    } 
    // start the process 
    fade(); 

JSFIDDLE

+0

Работает отлично. Особая благодарность. – Geme

Смежные вопросы