Mệnh đề if-else trong JavaScript
Độ rộng khung (px):
Chạy mã
Mã nhúng
Mở rộng
<html> <head> <script type="text/javascript"> function validateAge() { age = document.getElementById("age").value; if (age > 18) { alert("Du tuoi lao dong!"); } else { alert("Chua du tuoi lao dong!"); } } </script> </head> <body> Age: <input type="text" id="age" name="age" /> <input type="button" onclick="validateAge()" value="Submit" /> </body> </html>
Kết quả
Mã nhúng iFrame
Copy đoạn mã bên dưới để nhúng vào trang web của bạn:
<iframe src="https://viewcode.cunghocweb.com/trycode-full.php?id=73" style="width: 100%; height: 400px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;"></iframe>
Hoàn tất