问题描述

在设计表单时,表单内有一个按钮<button>,该按钮是用来获取其他数据或执行其他操作的。并不是让他提交表单。

解决方案

1) 设置 form 的 onsubmit='return false';

2)将按钮改成如下格式 <input type="button">

3) 在处理函数中使用

$( "a" ).click(function( event ) {
  event.preventDefault();
  $( "<div>" )
    .append( "default " + event.type + " prevented" )
    .appendTo( "#log" );
});

 

在 vue 中可以使用 prevent 修饰符进行修饰

 

相关文章:

  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-08-03
  • 2021-06-06
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案