console.log/document.write和Alert之间的区别 [英] difference between console.log / document.write and alert

查看:69
本文介绍了console.log/document.write和Alert之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会知道这三行代码有什么区别:

I would know what is the difference between those three lines of code :

console.log("");
document.write("");
alert(""); (or windows.alert("");)

推荐答案

console.log(")输出作为参数传递的任何内容.
例如 console.log("test")会将"test"输出到您的控制台

console.log("") outputs whatever is passed as the parameter.
e.g. console.log("test") will output "test" to your console

document.write(")将您想要的内容添加到html中.
例如 document.write(< p> paragraph</p>")将向文档添加新的段落

document.write("") adds whatever you want to html.
e.g. document.write("<p>paragraph</p>") will add a new paragraph to a document

alert(")是一个弹出警报.

这篇关于console.log/document.write和Alert之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆