I/T/JavaScript
Javascript switch문 사용법
황타
2009. 6. 16. 15:50
<SPAN id=tx_marker_caret></SPAN><?xml version="1.0" encoding="EUC-KR" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR" /> <title>Switch statement example</title> </head> <body> <script type="text/javascript"> var localDate = new Date(); var localTime = localDate.getHours(); document.write("Local Date : " + localDate + "<br/>"); switch (localTime) { case 4: document.write("4 hour"); case 9: document.write("9 hour"); default: document.write("else"); } </script> </body> </html>