In JavaScript, there are three common methods of binding events
The first approach
function written in the structure layer
Very bad, so that the page is very confusing, behavior and structure can not be separated
The second way to
Document is located above the HTML tag, it can be said to be the most powerful. The following example pops up "a" whenever you click anywhere on the page, using the document's characteristics.
Copy Code code as follows:
Get
JavaScript is a very flexible language, we can arbitrarily write various styles of code, different styles of code will also inevitably lead to the difference in the implementation efficiency, the development process of sporadic access to a number of
For a long time, never come up with a solution, everyone give some ideas.
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
1. Hammer.jsHammer.js is a widely used lightweight JavaScript framework that provides specifications for commonly used touch operations, such as contractions, drag-and-drop, double click and Delete, and so on. It supports most mobile platforms like
JavaScript does not have a function signature like any other programming language (what is a function signature, simply that the function accepts the parameter type and the number of parameters), and some people think that the return type should
First we create a new HTML file and write a fileupload and a button control.
The code is as follows:
Copy Code code as follows:
fileupload
"
Then, write a JavaScript OpenFile method.
The code is as follows:
Copy
The ECMAScript function does not care how many arguments are passed in, nor does it error because the parameters are not uniform. In fact, a function body can receive incoming arguments by arguments the object.
Copy Code code as follows:
Copy Code code as follows:
/**
* When this function is called, the class is created only if the first argument is passed in and the second does not exist
* When this function is called, two arguments are passed in, the first argument is the
Altkey, Button, cancelbubble, ClientX, ClientY, Ctrlkey, Fromelement, KeyCode, OffsetX, OffsetY, PropertyName, Returnvalu E, ScreenX,
ScreenY, Shiftkey, srcelement, Srcfilter, toelement, type, x, y
1.altKey Description: Check the status of the ALT
Examples are as follows:
$ ("Input[datatype=number]"). blur (function () {
var str = $ (this). Val ();
if (!isdecimal (str)) {
alert ("Please enter a number");
}
);
function Isdecimal
JavaScript scrolltop Gets the offset of the scroll bar relative to its top, such as making the "back Top" button that automatically displays hidden. The following problems are often encountered in practical
[1,2,3].length can get 3, "123". Length can also get 3, this slightly understand JS all know.
But Eval.length,regexp.length, "". tostring.length,1. What will tostring.length get?
Get 1,2,0,1, what do these numbers mean?
This is a group of new
Sometimes, we need to get the window drag or mouse movement distance, at this time by calculating the mouse before and after the position in the page to get the desired results, the following describes several event properties:
1, customer area
Nonsense not to say, realize the function of JS login Verification code need the following two steps, the concrete realization process is as follows:
1.js
var code= ""; The global definition validation code
function Createcode () {
code = "
1. What caused the Ajax cross-domain problem
Ajax itself actually interacts with the data through the XMLHttpRequest object, and the browser, for security reasons, does not allow the JS code to operate across domains, so it warns.
2. What is the
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