3 ms·
What if we had better JS in HTML? <form name="comment" onsubmit="event.preventDefault(); output.textContent = email.value"> <input name="email">
by sergeykish 6y ago
What if we had better JS in HTML?
<form name="comment" onsubmit="event.preventDefault(); output.textContent = email.value">
<input name="email">
<input type="submit">
<output name="output">
</form>
What if we made function and it was called with target as `this`?
<form onsubmit="commentOnSubmit(this)">...
<script>
function commentOnSubmit(comment) {
event.preventDefault()
comment.output.textContent = comment.email.value
}
I've heard it's possible now with React
const email = React.useRef(null)
return (
<form onSubmit={this.handleSubmit}>
<input ref={email} />