[자바스크립트 요약정리] confirm / prompt 사용예시
- 카테고리 없음
- 2017. 9. 5. 12:30
confirm은 확인을 누르면 true, 취소를 누르면 false가 반환되는 객체
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <!DOCTYPE html><html> <body> <input type="button" value="confirm" onclick="func_confirm()" /> <script> function func_confirm(){ if(confirm('ok?')){ alert('ok'); } else { alert('cancel'); } } </script> </body></html> |
prompt는 사용자 입력을 받아 입력값을 반환하는 객체
<!DOCTYPE html><html> <body> <input type="button" value="prompt" onclick="func_prompt()" /> <script> function func_prompt(){ if(prompt('id?') === 'egoing'){ alert('welcome'); } else { alert('fail'); } } </script> </body></html>이 글을 공유하기






