The code looks like this:
var arr = [5,32,28,66,2,15,3];
Arr.sort (function (A1,A2) {return
a1-a2;//a2-a1 input Reverse
});
Console.log (arr);
Console.log (Arr.reverse ()); Reverse reverse the order of elements in an array
var arr2
Then record the JavaScript access style sheet
JavaScript can access the style attributes of elements in a Web page, such as:
Accessing the Style property through JS
Alert (document.getElementById ("main"). Style.backgroundcolor);
Change the Style
Arrayobj.sort (sortfunction);
Parameters: Sortfunction
Options available. is the name of the function used to determine the order of elements. If this argument is omitted, then the elements are sorted in ascending order in ASCII characters.
The sort
This article focuses on the first reason. Finally, a development pattern is given to replace the traditional loop structure, which can completely avoid the situation that the script is out of control.
Original title:Speed up Your JavaScript, part 1
1, reference
A reference is a pointer to the actual position of the object. Look at the following examples of using references:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Splice in JavaScript is primarily used to manipulate arrays in JS, including deletions, additions, replacements, and so on.
Note: This method will change the original array!.
1. Delete-To delete the element, two parameters, the first argument (to
Copy Code code as follows:
function Get_cookie (name) {
var start = Document.cookie.indexOf (name+...= ...);
var len = start+name.length+1;
if ((!start) && (name!= document.cookie.substring (0,name.length)) return null;
if (start = =
First, the main points:
1. When the page load, the pictures coincide, stacked together [absolute positioning];
2. First show, other hidden;
3. Set subscript, set the color of the subscript to let it move with the picture;
4. Move the mouse to
1, typeof operator. There are no problems with functions, String, number, undefined objects of these types, but objects for array are useless:
JS Code
Copy Code code as follows:
Alert (typeof null); "Object"
Alert (typeof []);
Show ellipsis effect after JavaScript exceeds container
In the actual project, due to the length of the text content uncertainty and the fixed page layout, it is inevitable that the text content over the div (or other tags, the same below) area of
Copy Code code as follows:
/*
Purpose: Verify the format of IP address
Input: Strip:ip Address
Returns: False if return true through validation;
*/
function IsIP (StrIP) {
if (IsNull (StrIP)) return false;
var re =/^ (\d+) \. (\d+) \.
In the browser DOM event, there are some events that can be triggered uninterrupted by the user's actions. For example: Resize browser window size (resize), browser page scrolling (scroll), mouse Movement (MouseMove). In other words, when the user
Front.
As a common application of the date object in JavaScript, the simple calendar is widely used, this article will explain the realization of the simple calendar in detail.
Effect Demo
HTML descriptionUse the two input of type=number as the
High Simulation spring oscillator (compressed use version) after setting up the new activation element and then point me!! Run please activate & Lt;br> initial speed (in pixels per millisecond): " move interval (in milliseconds): half
Ways to add a function
function addevent (node, type, listener) {
if (Node.addeventlistener) {
The method of the Consortium (DOM method)
The false meaning in the following statement is for the bubbling phase, and if true is for the capture phase (ie
Now the realization of rounded corners is generally used to control the picture, this method has its advantages (resulting in a rounded angle smoothing). But at the same time he also asked for a consistent picture, if you want to dynamically change
jQuery function Parameter Pass
Use external variables in the function functions of jquery:
How to obtain I variable for
(i=0;i
JavaScript, JQuery detects whether a function exists
The method for detecting whether a function exists in
Dom after the completion of the implementation, has not been understood, based on some of the online method of logic does not understand, so go to the jquery source code research (ready function) of this article, write the following code (already
Copy Code code as follows:
Creates a new user object that accepts an object with many attributes as a parameter
function User (properties)
{
Iterate through all the properties of the object and ensure that it is scoped correctly
for (var i
The prerequisite is to install the Firebug plug-in and the Aptanadebugger plugin, their download address is as follows:Http://getfirebug.com/releases/firebug/1.2/firebug-1.2.0.xpi
Http://firefox.aptana.com/update/aptanadebugger.xpi
To start
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