Mệnh đề if-elseif-else trong JavaScript
Độ rộng khung (px):
Chạy mã
Mã nhúng
Mở rộng
<html> <head> <script type="text/javascript"> function checkMarks() { marks = document.getElementById("marks").value; if (marks < 50) { alert("Tạch!"); } else if (marks >= 80 && marks < 90) { alert("Xếp loại B"); } else if (marks >= 90 && marks < 100) { alert("Xếp loại A"); } else { alert("Xếp loại TB"); } } </script> </head> <body> Marks: <input type="text" id="marks" name="marks" /> <input type="button" onclick="checkMarks()" 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=71" style="width: 100%; height: 400px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;"></iframe>
Hoàn tất