DOMDOM
0posts
today
total
personal posts · since 2021

Fragments
of a day.

A small notebook for slow moments slipping by.

2023 IT Creator
2024 Food Creator
2025 News Creator
2026 News Creator

Latest Posts최근

tistory view

Back to Home

[javascript] alert 확인, 취소 버튼에 따라 다르게 코드작성하기

728x90
반응형

 

 

 

 

confirm으로 확인, 취소버튼을 누를지 체크하고

확인버튼을 눌렀을 때 (confirm == true)와

취소버튼을 눌렀을 때 (confirm == false)로 나누어

원하는 코드를 작성하면 됩니다 !!

 

 if (confirm("~~하시겠습니까?") == true){ 
   //true는 확인버튼을 눌렀을 때 코드 작성
   console.log("완료되었습니다.");
 }else{
   // false는 취소버튼을 눌렀을 때, 취소됨
   console.log("취소되었습니다");
 }

 

 

728x90
반응형

Comments

Thanks for staying up late.

keep wandering · keep listening