如何更改我的代码,以便如果用户按下“取消”,则以下代码将写入document.write("#DELETE")
或只是留出空白?
<!DOCTYPE html>
<html>
<body>
<script language="JavaScript">
var a = prompt("Put a text");
if (a === null || !a) {
document.write("");
} else {
document.write( "Your Text is: " + a );
}
</script>
</body>
</html>
答案 0 :(得分:0)
var radiuuss = prompt("Please set the radius");
document.write("Press 1 to put the code or press 2 to clear section");
if (radiuuss === null) {
document.write("#DELETE");
} else {
// document write a message with the value of the radiuuss.
}