javascript 如何在按钮单击时显示文本区域?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4814588/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to show text area on button click?
提问by in_herit
</html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"> 
$(document).ready(function(){
$("#popup").click(function(){
   // pop up a text area and I want to store value of textarea in a variable.
});
});
</script>
</head>
<body>
<form>
<textarea rows="2" cols="20" id="area" style="display:none"></textarea>
<input type="submit" id="popup" value="OK">
</body>
</html>
How to POPUP a text area on a button click?
如何在单击按钮时弹出文本区域?
回答by alex
var textarea = $('#area');
$("#popup").click(function(){
   // To show it
   textarea.show();
});
// To get the value
var value = textarea.val();
回答by Bebben
In jquery you can use $("#area").show()to display the element.
在 jquery 中,您可以$("#area").show()用来显示元素。
回答by Michael
If you're using jQuery, use the show method:
如果您使用 jQuery,请使用 show 方法:
$('#area').show();
You can also control the speed of the animation:
您还可以控制动画的速度:
$('#area').show("slow");
$('#area').show("fast");
Or you can specify an exact time in milliseconds. Here's the official documentation:
或者,您可以指定以毫秒为单位的确切时间。这是官方文档:

