How to use JavaScript to hide a text area
dom-events, html, javascript, textarea
Solution
Try like this
<script>
function showDiv1() {
var my_disply = document.getElementById('welcomeDiv1').style.display;
if(my_disply == "block")
document.getElementById('welcomeDiv1').style.display = "none";
else
document.getElementById('welcomeDiv1').style.display = "block";
}
</script>
It is the simple way of toggling the div using only one function,Ofcourse in JQuery there is only one thing you can do is 'toggle' the div
Problem
When I Click on the button a textarea appear allowing the user to type the message. After they type a message I want textarea to hide. Can any one help me how to hide the textarea after entering the message? This my Javascipt code: ``` <script> function showDiv1() { document.getElementById('welcomeDiv1').style.display = "block"; } </script> ``` This my html code: ``` <div> <span style="display: inline-block;text-align: center; margin:-73px 0px -10px 61px; "><a href ="#"><img src="/wp-content/uploads/2013/03/reject_5.jpg" width="60" height="60" style="margin:0px 0px 0px 0px" value="Show Div" onclick="showDiv()"/></a><br />Decline</span></div> <textarea id="welcomeDiv" style=" display:none; border:1px solid #666666; height:70px; margin:16px 0 0 8px " class="answer_list" title="Message to Employer" onFocus="this.value=''" > Message to Employer </textarea> ```