I have HTML
code to load an audio and write something about it, like this
<body>
<audio id="audio-player" controlsList="nodownload" controls src="1294.wav" oncontextmenu="return false;"
onkeydown="return false;">
Your browser does not support the audio element.
</audio>
<form>
<input type="hidden" name="sysid" id="sysid-field">
<textarea name="status" id="input_tr" autofocus></textarea>
<button type="submit" value="ok">OK</button>
</form>
I want to when user click on play
or pause
or any where on audio player
the focus
go back to textarea
Used this code but its not working for audio tag
const textarea = document.getElementById("input_tr");
document.body.addEventListener("click", function () {
// Set focus on the textarea element when the user clicks anywhere on the page
textarea.focus();
});
2
Answers
Try using
focus
event on audio elementHTML
Javascript