在不执行提交的表单内添加常规按钮

con*_*t01 28 html submit button

我有这个表格声明:

<form method="post" action="/web_services/buscar_vuelos?method=get">
  <div id="addSegment_wrapper">
    <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="addTr" style="display: inline;">
      <span class="ui-button-text">Add Segment</span>
    </button>
  </div>
  <input id="web_services_submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-          text-only" type="submit" value="Search" name="commit">
</form>
Run Code Online (Sandbox Code Playgroud)

而且,虽然我没有将"addSegment_wrapper"按钮指定为提交按钮,但每次单击它时,它都会调用表单操作.我只想将此按钮视为常规按钮.

我该怎么办?

谢谢

swi*_*itz 61

你可以做到

<button type="button">Add Segment</button>
Run Code Online (Sandbox Code Playgroud)


Cfr*_*eak 41

做这个:

<button type="button" class="(rest of your classes)">Rest of your code</button>
Run Code Online (Sandbox Code Playgroud)

  • 供参考...通过MDN:type = submit:该按钮将表单数据提交给服务器.*如果未指定属性*,或者属性动态更改为空值或无效值,则这是默认值.type = button:该按钮没有默认行为[...] (9认同)