[JavaScript] JavaScript learning 38 JavaScript examples

Source: Internet
Author: User
Basic JavaScript instance
Generate text

Generate common text and tags

Head Section

Body section

External Javascript

Example

Javascript statements, comments, and code blocks
Javascript statements

JavaScript code block

Javascript single line comment

Javascript multi-line comment

Use single line comment to prevent execution

Use multiline comments to prevent execution

Example

Javascript Variables
Declare a variable, assign values to it, and then display it

Example

Javascript Condition Statement if... else
If statement

If... else statement

If. Else if... else statement

Random Link

Example

Javascript message box
Warning box

Warning box with lines

Confirmation box

Prompt box

Example

JavaScript Functions
Function

Functions with Parameters

Function 2 with Parameters

Return Value Function

Functions with parameters and returned values

Example

Javascript loop
For Loop

Generate HTML titles cyclically

While Loop

Do WHILE LOOP

Break statement

Continue statement

Use the for... in Declaration to traverse the elements in the array

Example

Javascript error handling
Try... catch statement

Try... catch statement with confirmation box

Throw statement

Onerror event

Example

Advanced JavaScript instance
Detect browsers and versions

Detect more information about the browser

Detects all browser Information

Remind users based on browser type

Create a welcome cookie

Button Animation

Added JavaScript image ing.

Simple timing

Another simple timing

Timing events in an infinite loop

Timing events in an infinite loop with a stop button

Clocks and clocks created using timing events

Instance of the created object

Create an object Template

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.