Цитата:
<div class="div">click1</div> <div class="div">click2</div> <div class="div">click3</div> <style type="text/css"> .div {cursor: pointer; height: 20px;} .div2 {cursor: pointer; color: white; width: 0px;} </style> <script type="text/javascript"> window.onload = function(){ var div = document.getElementsByTagName('div'); for(i=0; i<div.length; i++){ div[i].onclick = function(){ var div = this, i = 0; (function(){ if(++i <= 300){ div.style.width = i+'px'; div.style.background = '#'+Math.round(Math.random()*100)+10000; div.setAttribute('class','div2'); div.innerHTML = parseInt(i/3)+'%'; setTimeout(arguments.callee, 10); } })(); }; } }; </script> |
monolithed,
на всякий случай div.style.background = '#'+Math.round(Math.random()*100)+10000; не все браузеры могут переварить 7-значный цвет, поэтому лучше так div.style.background = '#'+(Math.round(Math.random()*100)+100000); или так div.style.background = '#'+(Math.round(Math.random()*100)+100); |
monolithed, у автора темы был вопрос - как в setTimeout в функцию передавать параметры...
Вот и интересуюсь - как в твоём варианте передать параметры? |
Цитата:
|
Часовой пояс GMT +3, время: 13:01. |