1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

<button>タグがsubmitされるときの解決

Last updated at Posted at 2023-08-28

はじめに

モーダル制御などで、閉じるボタンに

<button></button>

を設定していて、JavaScriptで制御しようとしたらsubmitされてしまうため、思うように動かず。

解決策

<button type="button"></button>

formタグ内のbuttonタグは、type属性を設定しないとtype="submit"になるらしい。
思わぬ落とし穴。。

参考文献

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?