I am working on a user input interface which includes a textarea
for typing, along with a cancel
and submit
button.
Is there a way to show the cancel
and submit
buttons only when the user clicks inside the textarea
? (I prefer using vanilla JavaScript instead of jQuery)
I have tried implementing the following JavaScript function:
function controlButtons(userInput) {
if (userInput) {
document.getElementById('cfm').style.display = 'block';
document.getElementById('cancel').style.display = 'block';
}
else {
document.getElementById('cfm').style.display = 'none';
document.getElementById('cancel').style.display = 'none';
}
}
To trigger the display of buttons upon clicking inside the textarea, I used onClick="controlButtons(True)"
.
I'm still unsure whether this is the best approach. Any suggestions from experienced developers would be greatly helpful!