Basic JavaScript instance
Generate text
Generate common text and tags
Head Section
Body section
External Javascript
ExampleJavascript statements, comments, and code blocks
Javascript statements
JavaScript code block
‘ ‘js2015‘ so on;
[a-zA-Z\_\$][0-9a-zA-Z\_\$]*You can match a string consisting of a number, letter, or underscore, or $, which is the name of the variable allowed by JavaScript, by a letter or underscore, or $.
[a-zA-Z\_\$][0-9a-zA-Z\_\$]{0, 19}More precisely limit the length of a variable to 1-20 characters (1 characters before + 19 characters later).
a maximum of one trigger effect.The realization of underscoreThe underscore source code is as follows (with codes comments):Returns a function, that, as long as it continues to be invoked, would not//be triggered. The function would be called after it stops being called for//N milliseconds. If ' immediate ' is passed, trigger the function on the//leading edge, instead of the trailing.//de-jitter function, the incoming function executes after the wait
[1], holobby [2], holobby [3]V. Javascript variables:1. variable naming rules:The first character must be an uppercase or lowercase letter, underscore (_), or dollar sign ($). Subsequent characters can be letters, numbers, underscores, or dollar signs; the variable name cannot be a reserved word; the length is arbitrary; case sensitive;Convention: Set the cluster to top; use local variables whenever possib
This article will review the basic syntax in the ECMAScript specification. Good English friends can directly read the official documentation. JavaScript is essentially a type of C language. If you are familiar with C language, you can easily read this article or even skip it. However, it is recommended that you take a look at it, I may reference some common usage that I think is not easy to understand.
Basic syntax
1. identifier: the so-called identi
Traditionally, Javascript files are loaded using the script tag. We can also use the DOM method to dynamically load Javascript files. The specific implementation is as follows. If you are interested, refer to the traditional method, the script label is used to load Javascript files.
As shown below:
The javascript design pattern is turing Publishing. in learning, I want to focus on every chapter. Question:
1.1 javascript flexibility
Object-oriented Javascript programming mode: 1. Saving state 2. methods that can be called within an object 3. Better understanding of the structure of a program, able to withstand iterative development (in my opinion)
The Co
Document directory
Attribute
Method
1. Create an instance of the object
2. Create an object Template
Objects help organize information.Instance
Instance of the created object
This example shows how to create an instance of the javacripobject ).
Create an object Template
This example shows you how to create a template for a javacript object ).
JavaScript Object
In the previous section of this tutorial, we have learn
Javascript (1) Summary of javascript Array usage (2), javascript Array
// 1. array sorting. The default value is ascending. The sort () method calls the toString () of each item in the array, and then compares the obtained string to sort the result. // sort (): returns the sorted array // var arr = [23,1, 3,56, 42,-1]; // arr. sort (); // alert (arr); //-, // eve
also has special characters that are not visible at the beginning of the backslash (/). Often called control characters.
3, variable
The main function of variables is to access data and provide containers for storing information. For a variable, you must specify the name of the variable, the type of the variable, the declaration of the variable, and the scope of the variable.
Name of variable
The naming of variables in JavaScript is very similar to t
The first and second sections of this series introduce JavaScript module prototypes and theoretical concepts, and today we describe how they can be used in combat.
I'm using a very popular library require.js.
First, why use Require.js.
At the earliest, all of the JavaScript code was written in a file, and it was enough to load the file. Later, more and more code, a file is not enough, must be divided into
Getting StartedCharacter Matching
\d Match a number
\w matches an array or a letter
. Match any character
\s Match a space
Quantity Matching
* denotes any character (including 0)
+ indicates a minimum of one character
? Represents 0 or 1 characters
{n} represents n characters
{N,m} represents n-m characters ({} Yes, not-)
PS: Special characters, in regular expressions, to be ‘\‘ escapedPractice:
\d{3}\s+\d{3,8} Answer: Match 3 dig
We can use JavaScript to create dynamic images.Instance
Button Animation
Two different events are used to drive two corresponding functions, and two corresponding images are switched to create an animation effect.
Javascript Animation
It is feasible to create dynamic images using JavaScript.
TipsYes: use JavaSc
Document directory
Syntax
Instance
Instance-Infinite Loop
Syntax
Instance
By using JavaScript, we have the ability to execute code after a set interval, rather than immediately after the function is called. We call it a timing event.Instance
Simple timing
After you click the button in this example, a warning box will pop up in five seconds.
Another simple timing
In this example, the program runs 2 seconds, 4 seconds
Upgrade JavaScript (JavaScript you Don't know) to improve javascriptRecently, I have read the book "JavaScript (on-volume) You don't know", which details many important but often overlooked JavaScript points. I strongly recommend this book !!! In the book, Chapter 1 describes "Upgrade", describes the process of variabl
Javascript learning diary-prevents javascript events from bubbling and obtains the Control ID value
1. How to Prevent event bubbles
The Code is as follows:
// Non-IEIf (event event. stopPropagation)Event. stopPropagation ();Else // IEWindow. event. cancelBubble = true;
2. Get the Control ID
The Code is as follows:
If (document. all ){// IEAlert (event. srcElement. tagName + ":" + event. srcEl
How many seconds does function sleep in js? Javascript beginners often ask this question. Since the emergence of Javascript, this function is so necessary, but why does js not provide such a function?
Currently, all browsers parse js in the UI thread. Taking Firefox as an example, I re-compiled the js engine and added the sleep method to the js alert. This method calls the C language thread sleep functio
This article mainly introduces a simple example of implementing the TAB switch Effect of js (JavaScript). If you need it, you can refer to it and hope to help you with JavaScript) the tab Label Switching code of, can automatically adapt to the width, you can add and delete the label block yourself, you can complete the silly operation!
The Code is as follows:
19991224/loose. dtd ">
Adaptive width labe
Document directory
Instance 1
Instance 2
Syntax:
Instance
Syntax:
Instance:
The Condition Statement in Javascript is used to complete the action under different conditions.Instance
If statement
How to compile an if statement.
If... else statement
How to compile the IF... else statement.
If. Else if... else statement
How to compile the IF... else if... else statement
Random Link
This exam
This article mainly introduces how to increase the loading speed of javascript. write output js solves the problem of slow ad loading speed. If you need it, you can refer to it. Generally, some js Code will be loaded on our website, such as statistics, google ads, Baidu alliance, alimama advertising code,
The page loading speed was slow and slow.
Solution: Use a js inclusion method to increase the loading speed of
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.