Не выводит цвет
Всем приветы.
Помогите разобраться со скриптом. Где я мог допустить ошибку, не выводит в блок div сгенерированный цвет. $("#gencol").each(function (i) { var color = "#"+((1<<24)*Math.random()|0).toString(16); $(this).css("background-color",color); }); <div id="gencol" style="width:100px;height:100px;"></div> |
Dark_Delphin,
и давно у вас id размножается? |
Dark_Delphin,
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(function () { $(".gencol").each(function (i) { var color = "#" + ((1 << 24) * Math.random() | 0).toString(16); $(this).css("background-color", color); }); }) </script> </head> <body> <div class="gencol" style="width:100px;height:100px;"></div> <div class="gencol" style="width:100px;height:100px;"></div> <div class="gencol" style="width:100px;height:100px;"></div> </body> </html> |
Спасибо большое.
|
Часовой пояс GMT +3, время: 06:32. |