I want to show and hide a textarea on mobile to save space. The default behaviour is for the label to focus its associated textarea.
function showHideTextarea() {
if (textarea.style.display == "none") {
textarea.style.display = null; //remove display: "none" and revert to initial CSS value
textarea.focus()
}
else {
textarea.blur();
textarea.style.display = "none"
}
}
function resizer() {
if (window.matchMedia("(max-width: 766px)").matches) {
textarea.style.display = "none"
textlabel.addEventListener("click", showHideTextarea)
}
}
$(document).ready(resizer());
I’ve not been able to get this code to work.