我们如何在HTML中显示文本区域?

王林
发布: 2023-08-21 23:25:08
转载
2467人浏览过

我们如何在html中显示文本区域?

The task we are going to perform in this article is how do we display a text area in HTML. Let’s dive into the article for getting a clear idea on how we display text area.

HTML textarea标签定义了一个多行纯文本编辑控件。由于文本空间可以容纳无限数量的字符(通常是Courier),所以文本以固定宽度字体显示。在表单中,textarea通常用于收集用户输入,例如评论或评价。在提交表单后,表单数据中的引用将需要name属性。

Let’s look into the following examples to know more about how do we display a textarea in HTML.

Example 1

在下面的示例中,我们使用了多行输入控件。

立即学习前端免费学习笔记(深入)”;

MagicStudio
MagicStudio

图片处理必备效率神器!为你的图片提供神奇魔法

MagicStudio 102
查看详情 MagicStudio
<!DOCTYPE html>
<html>
<body>
   <form action="https://www.tutorialspoint.com/index.htm">
      <label for="name">NAME:</label><br>
      <input type="text" id="name" name="name"><br>
      <p><label for="comment">About Yourself:</label></p>
      <textarea id="comment" name="comment" rows="5" cols="35">
         I'm from Hyderabad,Telengana
      </textarea><br>
      <input type="submit" value="Submit">
   </form>
</body>
</html>
登录后复制

在运行上述脚本时,输出窗口弹出,显示了用于输入姓名的输入字段和用于自我介绍的文本区域,以及一个提交按钮。如果您点击提交按钮,表单将被提交。

Example 2:使用JavaScript

Considering the following example we are running script to change the context in the text area.

<!DOCTYPE html>
<html>
<body>
   Address:<br>
   <textarea id="tutorial">
      kavuri incore 9
      Hyderabad
   </textarea>
   <button type="button" onclick="myFunction()">Click To Change</button>
   <script>
      function myFunction() {
         document.getElementById("tutorial").value = "Madhapur , Telangana";
      }
   </script>
</body>
</html>
登录后复制
当脚本被执行时,它会生成一个输出,其中包含一个填充有文本的地址字段的文本区域,以及一个点击更改按钮

If the user clicks on the button, the text in the textarea gets changed.

Example 3

的中文翻译为:

示例3

<p>让我们考虑另一个例子,我们正在使用textarea标签</p>
<!DOCTYPE html>
<html>
<head>
   <title>HTML textarea Tag</title>
</head>
<body>
   <form action = "/cgi-bin/hello_get.cgi" method = "get">
      Enter subjects
      <br/>
      <textarea rows = "5" cols = "50" name = "description"></textarea>
      <input type = "submit" value = "submit" />
   </form>
</body>
</html>
登录后复制

When the script gets executed, the output window will pop up, providing the input type for textara along with a submit button.

以上就是我们如何在HTML中显示文本区域?的详细内容,更多请关注php中文网其它相关文章!

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:tutorialspoint网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号