Introduction to JavaScript

Source: Internet
Author: User
Tags button type

JavascriptIntroduction

JavaScript is the most popular scripting language on the Internet, which can be used in HTML and the Web, and is more widely used in servers, PCs, laptops, tablets and smartphones.

JavaScript is a scripting language

JavaScript is a lightweight programming language.

JavaScript is a programmatic code that can be inserted into an HTML page.

When JavaScript is inserted into an HTML page, it can be performed 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: Write directly to the HTML output stream instance document.write ("document.write ("<p> This is a paragraph. </p> ");
Try it»

You can only use document.write in HTML output. If you use this method after the document is loaded, the entire document is overwritten.

JavaScript: An example of a response to an event <button type= "button" onclick= "alert (' Welcome! ')" > I!</button>.
Try it»

The alert () function is not commonly used in JavaScript, but it is very handy for code testing.

The onclick event is just one of the many events you will learn in this tutorial.

JavaScript: changing HTML content

Using JavaScript to work with HTML content is a powerful feature.

Instance X=document.getelementbyid ("demo")//Find element
X.innerhtml= "Hello JavaScript"; Change Content
Try it»

You will often see document.getElementById ("some ID"). This method is defined in the HTML DOM.

The DOM (Document Object MOdel) (Document Object model) is the official standard for accessing HTML elements.

You'll learn more about HTML DOM in several chapters of this tutorial.

JavaScript: changing HTML images

This meeting dynamically changes the source of HTML <image> (SRC):

Light the light bulb.

Tap the light bulb to turn the lamp on or off


Try it»

JavaScript can change most attributes of any HTML element, not just pictures.

JavaScript: changing HTML styles

Changing the style of HTML elements is a variant of changing HTML attributes.

Instance X=document.getelementbyid ("demo")//Find element
X.style.color= "#ff0000"; Change Style
Try it»

JavaScript: Validating input

JavaScript is often used to validate user input.

instance if IsNaN (x) {alert ("not a Number")};
Try it»

Did you know that?

JavaScript and Java are two completely different languages, both conceptually and in design.
Java (invented by Sun) is a more complex programming language.

ECMA-262 is the official name of the JavaScript standard.

JavaScript was invented by Brendan Eich. It appeared in Netscape in 1995 (the browser has stopped updating) and was adopted by the ECMA (a standard association) in 1997.

Introduction to JavaScript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.