I have a question that I want to put an input in an alert box. What thing I have to do to create this? To make it I’ve to put an another tag, attrib, special properities, etc… Thanks. I think could be like this:
JavaScript
x
11
11
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<title>example</title>
5
</head>
6
<body>
7
<script type="text/javascript">
8
alert("<input></input>");
9
</script>
10
</body>
11
</html>
Advertisement
Answer
You can’t put anything in an alert box. As the name indicates, it’s an alert. You might be looking for a prompt which has an input text field, or confirm to get a true / false depending on user selection.
JavaScript
1
3
1
let foo = prompt('Type here');
2
let bar = confirm('Confirm or deny');
3
console.log(foo, bar);