+ 1
How to get user input on java script?
print stmt like document.write()
3 Antworten
+ 12
var a = prompt("Please enter your name");
alert(a);
+ 6
You could use prompt function or use form input and submit
<form onsubmit="get(this,event)">
<input type="type" name="i">
<input type="submit">
</form>
<script>
function get(e,evt){
evt.preventDefault();
alert(e.i.value);
}
</script>
https://code.sololearn.com/WC80ZyBuo47R/?ref=app
Don't use document.write(), it would erase the webpage with new write data, unless you intend to do it this way.
+ 4
use prompt("");