Prev Demo
How To Write Switch Statement In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <script> function Check() { var myName = document.getElementById("txtName").value; switch (myName) { case "Sheo": alert("Yes"); // other statements break; case "sheo": alert("yes"); // other statements break; default: alert("No"); // other statemetns break; } } </script> Enter your name: <input type="text" id="txtName" /> <input type="button" id="btnSubmit" value="Check my name" onclick="Check()" /> </body> </html>
Note: We DO NOT save your trial code in our database.
Output