Introduction to JavaScript
JavaScript Introduction
JavaScript is the most popular scripting language on the Internet. This language can be used for HTML and web, and can be widely used on servers, PCs, laptops, and tablets. and devices such as smartphones.
JavaScript is a scripting language
JavaScript is a lightweight programming language.
JavaScript is programming code that can be inserted into HTML pages.
JavaScript, when inserted into an HTML page, can be executed by all modern browsers.
JavaScript is easy to learn.
What you will learn
Here are the main things you will learn in this tutorial.
JavaScript 能够直接写入 HTML 输出流中:
您只能在 HTML 输出流中使用 document.write。 如果您在文档已加载后使用它(比如在函数中),会覆盖整个文档。
Warm reminder: You can only use document.write in HTML output. If you use this method after the document is loaded, the entire document will be overwritten.
JavaScript: Reaction to events:
JavaScript
JavaScript 能够对事件作出反应。比如对按钮的点击:
Warm reminder: The alert() function is not commonly used in JavaScript, but it is useful for code Testing is very convenient. The
onclick event is just one of many events you'll learn about in this tutorial.
JavaScript: Changing HTML content
Using JavaScript to process HTML content is a very powerful feature.
JavaScript
JavaScript 能改变 HTML 元素的内容。
You will often see document.getElementById("some id"). This method is defined in the HTML DOM.
DOM (Document Object Model) is the official W3C standard for accessing HTML elements.
You will learn about the HTML DOM in several chapters of this tutorial.
JavaScript: Change HTML style
Changing the style of HTML elements is a variant of changing HTML attributes.
JavaScript
JavaScript 能改变 HTML 元素的样式。
JavaScript: Validating Input
JavaScript is often used to validate user input.
我的第一段 JavaScript
请输入数字。如果输入值不是数字,浏览器会弹出提示框。