js输出语句
-
alert();
-
console.log(); 可以打印多个
-
document.write();
-
document.write();alert();只能打印一个
-
区别:
-
alert();弹框体验太差
-
document.write();将内容输出到页面上可能会破坏页面的结构
-
上面的两个的共同点就是你给我的我给你输出仅仅是输出
-
console.log();建议使用这个,这个有个好处我能获取更详细的信息
-
代码演示
-
<script>
alert('hello world'); //弹出框alert(123);alert(456);
console.log('hello world'); //控制台输出
document.write('hello world'); //页面输出
</script>
-
输入语句
-
prompt('提示内容','默认内容');
-
代码演示
-
<script>
alert (prompt('想辉煌腾达吗,那就努力把','18岁的孩子'));
</script>
<script>
prompt('提示用户的内容','输入框内部默认的内容');
alert(prompt('请输入你的年龄','18'));
// 用户输入完以后,点击确定,会弹出输入的内容
</script>






