![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 266 Pomógł: 0 Dołączył: 4.01.2007 Skąd: Szczecin Ostrzeżenie: (0%) ![]() ![]() |
Witam,
w jaki sposób zrobić zmiane div po x czasie? Chodzi mi bardziej o to, że jak div o danym id nie istnieje to nie idzie na początek...
z tym, że jak myDiv_5 albo myDiv_6 nie istnieje to kończy prace... a jak zrobić, że od początku przesuwało? Próbowałem też pętlą, ale nic mi nie wyszło...
Ten post edytował SN@JPER^ 16.10.2011, 14:23:03 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 266 Pomógł: 0 Dołączył: 4.01.2007 Skąd: Szczecin Ostrzeżenie: (0%) ![]() ![]() |
Zrobilem tak jak mówiles - dodalem do prototypu, usunałem var. a w li zrobiłem tak:
Kod <li><a id="mainss_<?php echo $i;?>" onclick="oSH.showAc();"><?php echo $i;?></a></li> JS Kod function ShowHide(){ this._aEl = []; } ShowHide.prototype = { _aEl: null, _sHideClass: 'contentdiv none', _sShowClass: 'contentdiv block', _i:0, _interval:null, setElements: function(sPrefix,iBegin, iEnd){ var el, ar = this._aEl; for(var i = iBegin; i<=iEnd; ++i){ el = document.getElementById(sPrefix+i); if(!!el) ar[ar.length] = el; } el = ar = null; return this; }, hideAll: function(){ for(var s=this._sHideClass,i=0,a=this._aEl,iL = a.length; i<iL;++i) a[i].setAttribute('class', s); return this; }, showFirst: function(){ if(this._aEl[0]) this._aEl[0].setAttribute('class', this._sShowClass); return this; }, showNext: function(){ var a = this._aEl; if(a.length){ a[this._i].setAttribute('class', this._sHideClass); if(this._i<(a.length-1)){ ++this._i; }else{ this._i=0; } a[this._i].setAttribute('class', this._sShowClass); } a= null; return this; }, showAc: function(i){if(this._aEl[i-1]) {//index'y są od 0 a nie od jeden this._aEl[i-1].setAttribute('class', this._sShowClass); this._i = i; } // return this nie musi być - jak uważasz return this;}, startInterval:function(i){ if(!i) i = 1000; this._interval = setInterval((function(ob){ return function(){ ob.showNext(); } })(this),i); return this; }, stopInterval:function(){ clearInterval(this._interval); return this; } }; onload=function() { // PRZYKŁADOWE UŻYCIE oSH = new ShowHide(); oSH .setElements('mains_', 0, 6) .hideAll() .showFirst() .startInterval(5000); I nie działa, zadnego efektu. Konsola FF tez nic nie pokazuje. Ten post edytował SN@JPER^ 19.10.2011, 16:43:03 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 6.10.2025 - 19:44 |