Sublime Text
<!DOCTYPE html> <html> <body> <button type="button" onclick="abc()">Click here</button> <p id="demo"></p> <script> function abc(){ var fullName = prompt("Nhập họ tên của bạn:"); if(fullName != null){ document.getElementById("demo").innerHTML = "Họ tên: " + fullName; }else{ document.getElementById("demo").innerHTML = "Bạn đã bấm nút hủy"; } } </script> </body> </html>
<!DOCTYPE html> <html> <body> <button type="button" onclick="abc()">Click here</button> <p id="demo"></p> <script> function abc(){ var fullName = prompt("Nhập họ tên của bạn:"); if(fullName != null){ document.getElementById("demo").innerHTML = "Họ tên: " + fullName; }else{ document.getElementById("demo").innerHTML = "Bạn đã bấm nút hủy"; } } </script> </body> </html>