<a onclick='callCHATGPT()' class='btn btn-large' href='#' style='background-color: #4cae4c; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none;' onmousedown='this.style.backgroundColor='#3c903c'' onmouseup='this.style.backgroundColor='#4cae4c''>回答 <a onclick='clearTextArea()' class='btn btn-large' href='#' style='background-color: #d9534f; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none; margin-left: 20px;' onmousedown='this.style.backgroundColor='#c9302c'' onmouseup='this.style.backgroundColor='#d9534f''>清空

将 Button 按钮转换为 A 标签按钮,可以保留原有的按钮样式,同时实现链接跳转的功能。

具体步骤:

  1. <button> 标签替换为 <a> 标签。
  2. 保留原有的 classstyleonclick 属性。
  3. 添加 href 属性,指定链接的目标地址。

代码示例:

<a onclick='callCHATGPT()' class='btn btn-large' href='#' style='background-color: #4cae4c; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none;' onmousedown='this.style.backgroundColor='#3c903c'' onmouseup='this.style.backgroundColor='#4cae4c''>回答</a>
<a onclick='clearTextArea()' class='btn btn-large' href='#' style='background-color: #d9534f; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none; margin-left: 20px;' onmousedown='this.style.backgroundColor='#c9302c'' onmouseup='this.style.backgroundColor='#d9534f''>清空</a>

注意:

  • href 属性的值可以是任何有效的 URL 地址。
  • 如果您需要在点击按钮时执行 JavaScript 代码,请使用 onclick 属性。
  • 您可以根据需要调整按钮的样式属性。
将 Button 按钮转换为 A 标签按钮

原文地址: https://www.cveoy.top/t/topic/mmV3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录