휴지통

html button 클릭시 페이지 새로고침되는 이유

좌포이동건 2022. 12. 20. 05:27

html에서 button의 기본값은 submit이기때문에 페이지 전송용도가아니라 별도 함수를 지정하여 사용하려는경우 반드시 button type 을 button으로 지정해주어야한다.

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

 

참고  -

https://stackoverflow.com/questions/7803814/how-can-i-prevent-refresh-of-page-when-button-inside-form-is-clicked