gpt-4-1106-preview· openai
Suzhen/CodeChat
HTML page with one button and an empty div
- User
HTML page with one button and an empty div
- Assistant
Here's a simple HTML page with a button and an empty
div. When the button is clicked, you can perform an action, such as filling thedivwith content using JavaScript.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Simple Button and Div Example</title> <script> // Function to be called when the button is clicked function onButtonClick() { // Locate the div with id "contentDiv" and change its HTML document.getElementById("contentDiv").innerHTML = "Content added to div!"; } </script> </head> <body> <!-- Button that, when clicked, calls the onButtonClick() function --> <button onclick="onButtonClick()">Click Me</button> <!-- Empty div where content can be added --> <div id="contentDiv"></div> </body> </html>