首页 > 解决方案 > 用于表单操作的 HTML 和 CSS 按钮

问题描述

我正在为 HTML 和 CSS 中的两个人创建两个联系按钮。我的目标是在单击按钮时,用户将使用 Outlook 平台直接向他们发送邮件。我的 person1 代码如下:

<p><form action="mailto:abc@google.com" method="post" enctype="text/plain"><button class="button1" a href="mailto:abc@google.com">Contact</button></p> 

它创建了一个联系按钮,单击该按钮时它会在 Outlook 中显示邮件 ID 为 abc@google.com。这是完美的。

现在 person2 的代码如下:

<p><form action="mailto:xyz@google.com" method="post" enctype="text/plain"><button class="button1" a href="mailto:mailto:xyz@google.com">Contact</button></p> 

但是在这里,当单击“联系人”按钮而不是显示“xyz@google.com”id 时,它显示了 person1 的 id,即 abc@google.com。

我无法解决这个问题。

标签: htmlcssforms

解决方案


只需添加结束标签form,并更正这一行 - a href="mailto:xyz@google.com"

<form action="mailto:abc@google.com" method="post" enctype="text/plain">
  <button class="button1" a href="mailto:abc@google.com">Contact</button>
</form>

<form action="mailto:xyz@google.com" method="post" enctype="text/plain">
  <button class="button1" a href="mailto:xyz@google.com">Contact</button>
</form>


推荐阅读