Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en"> <meta charset="utf-8"/>
- <body id = "textId" >
- <center>
- <p style = "color:red;background:white;">
- WHAT COLOR?
- </p>
- <button onclick = "changeColor()">
- Change!!!
- </button>
- </center>
- <script>
- function randIntr(Hl) {
- return Math.floor(Math.random() * (Hl + 1) ) ;
- }
- function changeColor(){
- var text = document.getElementById("textId");
- text.style = "background:rgb("+randIntr(255)+","+randIntr(255)+','+randIntr(255) + ");";
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement