2022年6月24日星期五

[React]press enter to submit without form

 <label for="email">Email:</label><br />

<input type="text" value={email} onChange={e => setEmail(e.target.value)} name="email" /><br />

<label for="password">Password:</label><br />

<input type="text" value={password}

onChange={e => { setPassword(e.target.value); }}

onKeyDown={e => { e.key === 'Enter' ? handleSubmit() : () => { } }}

/><br /><br />

<button className='btn btn-primary' onClick={handleSubmit}>Submit</button>

沒有留言:

發佈留言

[Fixed] some windows chrome, scrolling has glitch position not accurate

   [Fixed] some windows chrome, scrolling has glitch position not accurate Smooth Scrolling Flag 📜 Chrome has an experimental "smooth ...