screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [inputValue, setInputValue] = useState(''); // State to store input value const handleInputChange = (event) => { setInputValue(event.target.value); // Update input value in state }; const handleButtonClick = () => { console.log('Input value:', inputValue); // Log the input value when button is clicked }; return ( <div className='container'> <h3>React Js Get value of Input Field on Button click</h3> <input type="text" value={inputValue} onChange={handleInputChange} /> <button onClick={handleButtonClick}>Get Value</button> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> .container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background-color: #f5f5f5; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } h3 { font-size: 24px; margin-bottom: 20px; color: #333; } input { padding: 10px; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 10px; font-size: 16px; width: 100%; } button { padding: 10px 20px; background-color: #007bff; border: none; border-radius: 5px; color: #fff; font-size: 16px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #0056b3; } </style> </body> </html>