JavaScript Output
JS can "display" data in different ways:
(1)Writing into an alert box, using window.alert();
<!DOCTYPE html>
<html>
<body>
<h1>My first example.</h1>
<script>
window.alert(5 * 6);
</script>
</body>
</html>
(2)Writing into the HTML output using document.write();
<script>
document.write(5 + 8);
</script>
But, using document.write() after an HTML document is fully loaded, will delete all existing HTML:
<!DOCTYPE html>
<html>
<body> <h1>My First Web Page</h1>
<p>My first paragraph.</p> <button onclick="document.write(5 + 6)">Try it</button> </body>
</html>
(3)Writing into an HTML element, using innerHTML;
<!DOCTYPE html>
<html>
<body> <h1>My First Web Page</h1>
<p>My First Paragraph.</p> <p id="demo"></p> <script>
document.getElementById("demo").innerHTML = 5 + 6;
</script> </body>
</html>
(4)Writing into the browser console, using console.log().
<!DOCTYPE html>
<html>
<body> <h1>My First Web Page</h1>
<p>My first paragraph.</p> <p>
Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.
</p> <script>
console.log(5 + 6);
</script> </body>
</html>
这样就可以按F12调试自己的代码了。
JavaScript Output的更多相关文章
- [TypeScript] 建置输出单一JavaScript档案(.js)与Declaration档案(.d.ts)
[TypeScript] 建置输出单一JavaScript档案(.js)与Declaration档案(.d.ts) 问题情景 开发人员使用Visual Studio来开发TypeScript,可以很方 ...
- 4-14-17 JavaScript知识点总结(包括JOSN, ajax等,来源w3c)
JavaScript 也称 ECMAScript as "JavaScript" It is designed to run as a scripting language in ...
- html5--3.18 新增的output元素
html5--3.18 新增的output元素 学习要点 了解output元素的用法 output元素:数据的输出 output元素是HTML5新增的元素,用来设置不同数据的输出 output元素的输 ...
- html5中output元素详解
html5中output元素详解 一.总结 一句话总结: output元素是HTML5新增的元素,用来设置不同数据的输出,没什么大用,了解即可 <form action="L3_01. ...
- JavaScript高级特征之面向对象笔记
Javascript面向对象 函数 * Arguments对象: * Arguments对象是数组对象 * Arguments对象的length属性可以获取参数的个数 * 利用Arguments对象模 ...
- coffeescript 1.8.0 documents
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...
- HTML5 使用 JS 生成二维码,带头像
一般在项目开发中,前端显示给用户扫描的二维码基本都是由后端代码生成的,那么这个高大上的功能能不能用 JS 来绘制呢? 答案是肯定的 首先我们需要一个插件 jquery.qrcode.js,该插件基于 ...
- 高级js--(面向对象js,arguments,闭包,自调)
1. Arguments对象 l检测参数个数 1.在函数代码中,使用特殊对象 arguments,开发者无需明确指出参数名,就能访问它们. function howManyArgs() { al ...
- Web安全开发建议
版权声明:原创作品,如需转载,请与作者联系.否则将追究法律责任. Web安全问题,很多时候会被人所忽略,安全漏洞造成了很多不必要的维护和开发任务,产生的问题有时候更是致命的. 实际上,只要我们养成一些 ...
随机推荐
- 普通用户加sudo权限
没配置之前希望在普通用户下,通过sudo命令,让用户暂时拥有root权限,并创建一个文件夹.很明显,失败了,错误原因是:该用户暂没有root权限. 解决办法如下 1.打开sudoers文件 切换到r ...
- Axis2 WebService(配置、发布、调用)
准备工作 1.下载:axis2-1.5.4-bin.zip,axis2-1.5.4-war.zip 下载地址:http://axis.apache.org/axis2/java/core/ 2.环境变 ...
- [洛谷P2852] [USACO06DEC]牛奶模式Milk Patterns
洛谷题目链接:[USACO06DEC]牛奶模式Milk Patterns 题目描述 Farmer John has noticed that the quality of milk given by ...
- [uva11991]map和vector的入门
给你一个长度为n的数组,进行m次询问,每次询问输入k和v,输出第k次出现v时的下标是多少. n<=1e6 用vector动态开空间,map使数值结合.map每次查找效率大约为logn. map的 ...
- Android通知栏介绍与适配总结
由于历史原因,Android在发布之初对通知栏Notification的设计相当简单,而如今面对各式各样的通知栏玩法,谷歌也不得不对其进行更新迭代调整,增加新功能的同时,也在不断地改变样式,试图迎合更 ...
- IT培训班123
最近20年,IT行业一直处于上升期,程序员的工资越来越高了,年薪几十万的程序员大有人在.根据国家统计局发布的2016年各行业平均工资报表,程序员已经是工资最高的一个群体,超过了金融行业. IT行业的火 ...
- js localtion.href 数据传输
1.今天发现的一种数据发送 如下标红 <script> <%--测试juquery的代码如下操作.我们可以看出使用juquery 进行选择标签的属性可以更加方便--%> con ...
- Revison
- Optimizing subroutine calls based on architecture level of called subroutine
A technique is provided for generating stubs. A processing circuit receives a call to a called funct ...
- linux-open-source-development-tools【重点】
https://www.pluralsight.com/blog/software-development/linux-open-source-development-tools https://ww ...