gpt-4o-2024-11-20· openai
from WildChat-4.8M
generate html>css>javascript OR HTML OR CSS OR JAVASCRIPT code block into chat
- User
generate html>css>javascript OR HTML OR CSS OR JAVASCRIPT code block into chat
- Assistant
Sure! Here's an example of HTML, CSS, and JavaScript code combined to create a simple interactive button that changes the background color when clicked:
HTML Code:
html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Interactive Button</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Click the Button to Change Background Color</h1> <button id="colorButton">Change Color</button> </div> <script src="script.js"></script> </body> </html>
CSS Code (style.css):
cssbody { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f4f4f4; transition: background-color 0.5s ease; } .container { text-align: center; } button { background-color: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 5px; font-size: 16px; cursor: pointer; transition: transform 0.2s ease, background-color 0.3s ease; } button:hover { transform: scale(1.1); background-color: #0056b3; }
JavaScript Code (script.js):
javascript// JavaScript to handle button click and change background color const button = document.getElementById('colorButton'); button.addEventListener('click', () => { // Generate random color const randomColor = `#${Math.floor(Math.random() * 16777215).toString(16)}`; // Change background color of body document.body.style.backgroundColor = randomColor; });
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.