<div id="app"></div>
const App = () => {
const handler = (event) => {
window.alert(`你選擇了:${event.target.value}`);
}
return (
<div>
<select onChange={ handler } name="location">
<option value="Taipei">台北</option>
<option value="Taoyuan">桃園</option>
<option value="Hsinchu">新竹</option>
</select>
</div>
)
}
const app = document.querySelector('#app');
const root = ReactDOM.createRoot(app);
root.render(<App />);
View Compiled
This Pen doesn't use any external CSS resources.