// Obtain the Control ID list containing a string in a container control.
// Parameter: Container Control, Id keyword of the control to be searched, and Tag Name of the control to be searched
// Return value: string of the retrieved Control ID list,
The depressing thing is coming. first look at the front-end HTML:
CopyCode The Code is as follows: purchase quantity:
Parts (Inventory )
Use JS values. Pay attention to the JS Code:Copy codeThe Code is as follows: var num = Document.
First, let's take a look at the basic knowledge:
1. What is cookie?
Cookie is a variable stored on the visitor's computer. This cookie is sent every time a computer requests a page through a browser. You can use JavaScript to create and retrieve
I. function
From the very beginning, when I got started with JavaScript, I felt flexible. Everyone's writing methods were different. For example, a function had N writing methods.
For example: function showMsg () {}, var showMsg = function () {},
1. IntroductionIn the previous article "how to ensure the execution sequence of JavaScript-jquery.htmldeep analysis", we revealed that the jquery.html function can be executed dynamically in JavaScript in various browsers. The secret is that AJAX
The simplest way to create a namespace is:
Copy codeThe Code is as follows: var java = {};
Java. util = {};
// The namespace is successfully created: java. util
// We can add classes (functions), attributes, or objects under java. util.
Java. util.
The first is the most common method:
Program code
Copy codeThe Code is as follows: test
One day, when we know that JavaScript is to be separated from the HTML structure, we will change the Syntax:Program codeCopy codeThe Code is as follows: Test
AppendChild DefinitionAppendChild (newChild: Node): NodeAppends a node to the childNodes array for the node.Supported: IE 5.0 +, Mozilla 1.0 +, Netscape 6.0 +, Safari 1.0 +, and Opera 7.0 +Add a node to the child node array of the specified node. It
Implementation 1
Copy codeThe Code is as follows: String. prototype. trim = function (){
Return this. replace (/^ \ s */, ''). replace (/\ s * $ /,'');
}
It looks pretty bad. I used two regular expressions to replace it. The actual speed is amazing,
1. Avoid using eval or Function Constructor
2. Avoid using
3. Do not use try-catch-finally in functions with performance requirements.
4. Avoid using global variables
5. Avoid using for-in functions with performance requirements.
6. Use string to
Self-executed function: automatically executed function. It is already running when it is explained. Generally, functions are executed only when called.
General Format of Self-executed functions: (function () {function body })();
In addition,
Of course, we can get the parameter value in the background, and then get the variable value in the front-end js Code. For details, refer to my article: javaScript obtains the C # variable in the background and calls the background method.
In
Copy codeThe Code is as follows: function f1 (){
Var n = 999;
NAdd = function () {n + = 1 ;}
Function f2 (){
Alert (n );
}
Return f2;
}
Here, the closure is f1, which closes a Variable n and a function f2.
We will ignore nAdd and try to rewrite this
Caller:
FunctionName. caller returns the caller.
Let's take a look at the following functions. You can copy them to VS and execute them.Copy codeThe Code is as follows: function caller (){If (caller. caller ){Alert (caller. caller. toString ());}
Add the following code to the beginning of JavaScript
Copy codeThe Code is as follows:/* @ cc_on _ d = document; eval ('var document = _ D ')@*/
The document with such a line of code IE can be accessed at least five times fasterThe following is the
Recently, some of the functions of the project are being reconstructed, and the front-end has basically overturned the original design. In the past six months, there have been new solutions. In the past few days, we have encountered some problems in
The following code defines classes using javascript:
Specify the class name and constructor. The first letter of the Class Name (constructor name) is uppercase:Copy codeThe Code is as follows: function YourClass (){}
The "this. member variable"
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.