Функция next() или незнаюю
При нажатии на кнопку следующий надо сменит картинку
----------------------[html]----------------------------------- <div id="headerPhoto"> <img src="images/photos01.jpg" width="100%"/> </div> <div id="next01"> <a href="#"> следующий </a></div> <div id="small" > <a href="images/photos02.jpg"><img src="upload/p01.jpg" width="96" height="64" /></a> <a href="images/photos01.jpg"><img src="upload/p02.jpg" width="96" height="64" /></a> <a href="images/photos01.jpg"><img src="upload/p03.jpg" width="96" height="64" /></a> </div> ----------------------------------------------------------------------------- -------------------------------[script]--------------------------------------- $('#small a').click(function(eventObject){ $('#headerPhoto img').hide(1).attr('src',$(this).attr('href')); $('#headerPhoto img').load(function(){ $(this).fadeIn(2000); }); eventObject.preventDefault(); $('#next01').click() ????????? а дальше не знаю помогитее плииииииз }); ----------------------------------------------------------------------------- |
function next(items) { var max = items.length - 1, i = -1; return function () { i = i < max ? i + 1 : 0; return items[i]; }; } var imagName = next(['p01', 'p02', 'p03']); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); |
не понял ((((((((((
|
Poznakomlus, вариант...
function next(items) { var max = items.length, i = 0; return function () { return items[i++ % max]; }; } var imagName = next(['p01', 'p02', 'p03']); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); |
Цитата:
|
Цитата:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <script> function next(items) { var max = items.length, i = -1; return function () { i++; i %= max; return items[i]; }; } var imagName = next(['p01', 'p02', 'p03']); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); alert('upload/' + imagName() + '.jpg'); </script> </body> </html> |
Часовой пояс GMT +3, время: 05:48. |