JS can "display" data in different ways:
(1)Writing into an alert box, using window.alert();
1 2 3 4My first example.
5 8 9
(2)Writing into the HTML output using document.write();
1
But, using document.write() after an HTML document is fully loaded, will delete all existing HTML:
My First Web Page
My first paragraph.
(3)Writing into an HTML element, using innerHTML;
1 2 3 4 5My First Web Page
6My First Paragraph.
7 8 9 10 13 14 15
(4)Writing into the browser console, using console.log().
1 2 3 4 5My First Web Page
6My first paragraph.
7 89 Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.10
11 12 15 16 17
这样就可以按F12调试自己的代码了。