You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Актуальные контакты:
Telegram: @Nikker_web
E-Mail: tarasevich.email@gmail.com
Портфолио https://www.behance.net/d4d4186e
Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ
Актуальные контакты:
Telegram: @Nikker_web
E-Mail: tarasevich.email@gmail.com
Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ
Портфолио https://www.behance.net/d4d4186e
Question
samec1337
Приветствую!
Имеется код, в котором переменная "t" содержит случайный цвет.
Как сделать, чтобы при нажатии на кнопку, div заливался случайным цветом?
<html><head> <meta charset="utf-8"> <style> #box { width: 25px; height: 25px; border: 1px solid black; margin: 20px; } </style></head><body> <input type="button" onclick="randomColor()" value="ЖМИ"> <div id="box"></div> <script> function randomColor() { document.getElementById("box").style.backgroundColor = "red"; var t = '#' + (Math.round(Math.random(99999999, 1) * 99999999)).toString(16).substr(1);} </script></body></html>(В примере указал заданный цвет "red". С ним работает).
Link to comment
Share on other sites
9 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.