Js Code optimization record

1. Simple Example:Switch caseCopy codeThe Code is as follows:Var caseContent = ''; // content after condition judgmentVar caseValue = 5; // condition judgment ValueSwitch (caseValue ){Case 0:CaseContent = "Shoes ";Break;Case 1:CaseContent = "Pants ";

Public and private objects in JS, that is, static Modifiers

Copy codeThe Code is as follows:// Re-encapsulate the document ObjectVar Console = {Write: function (msg) {alert (msg );}};// Person objectVar Person = {_ Name: "zzl", // static public_ Age: 28,PrintInfo: function () {Console. write ("name:" +

FormStorage is a jquery-based plug-in that stores the state of elements in a form to a local location)

The principle is very simple. Through the local storage mechanism (userData or localStorage), the state of elements in the form is stored locally. You can restore the stored state to the form element when necessary. The json data format is also used.

MooBox dialog box plug-in based on Mootools

On the one hand, out of interest in mootools (although not as hot as jQuery), on the other hand, it also wants to add a little power to the promotion of mootools, although this is insignificant. With the two previously released mootools components,

GetElementByIdx_x js custom getElementById Function

Function Code:Copy codeThe Code is as follows:Document. getElementByIdx_x = function (id ){If (typeof id = 'string ')Return document. getElementById (id );ElseThrow new error ('Please pass a string as a id! ')} Instance code:Copy codeThe Code is as

Prototype source code analysis part Number

The Number method is relatively small. There are eight methods in total:ToColorPart: converts a Number object to a hexadecimal format with two digitsSucc: returns the next value of the current Number object, that is, the current value plus one.Times:

Operation js Code for the default value of the text box

For example:Search box: Text area: You can enter your suggestions or comments to create more convenient services for your website... ........First of all, this kind of prompt function is very good and intuitive, but how to clear the content when

Js-implemented perfect time component upgrade for Sina Weibo imitation

This time component was sent once before, and the last time it was very bad. This time it was time to upgrade it. The performance is better and it is perfectly compatible with all browsers. The ie6 drop-down select file is not available.In short, it

Js Chinese Character sorting problems support Chinese and English hybrid sorting, compatible with various browsers, including CHROME

Specific Technology 1. Use GB encoding and UNICODE Conversion2. array Association sortingNote: GB encoding library address http://demo.jb51.net/jslib/qswhGB2312.jsCode (the demo is very simple)Copy codeThe Code is as follows: Note: This sorting

Jquery plug-in is designed to hide some rows on the SageCRM query screen.

Solution:1. Add a [-] [+] to the title for users to click.2. the user's behavior of shrinking and expanding the screen is saved in the Cookie. You can still remember your behavior when you reload the page or log on to the system again.   Advantages:

Jquery event mechanism extension jquery right-click events.

Jquery's event mechanism is actually perfect, including clicking, double-clicking, moving the mouse in, and moving the mouse out. However, one event is missing. That is, right-click the event. Of course, you can also directly listen to the mouse and

Implementation Code for building the DOM node Structure of a page using JS

TIPS:The concat and push methods of arrays.The main differences between the two are:Concat is a connected array and does not modify the original array. The returned value is the connected array. An important difference between concat and push is

Analysis of peat leopard-like participation in real parameters in javascript Pipe

Introduction:Today, I saw a question from someone else:Copy codeThe Code is as follows:Function fn (x ){X = 10;Arguments [0] = 20;Console. log (x, arguments [0])}Fn () I feel like I have no idea about this. I can try it myself, so I will analyze it

Use nodejs to Access ActiveX objects.

CauseSomeone asked, "If nodejs is used to access SQL server ?"After finding the information, I found two solutions: Use the third-party nodejs plug-in: https://github.com/orenmazor/node-tds、to use the

Jquery-based Drag layout plug-in

Copy codeThe Code is as follows:(Function ($ ){$. Fn. lsMovePanel = function (){Var id = this. attr ("id ");Var X = Y = 0;Var offsetX = offsetY = 0; // absolute positionVar OldIndex = 0; // store the original IndexVar Temp_Li = " ";Var Move_obj; //

A shopping cart similar to a shopping mall Based on JQuery

Product Information is simulated using JSON dataIf you click the same product multiple times, you will not add it again. Instead, the number of existing products is + 1,You can also manually enter the number of items. If you enter 0, the item will

Analysis on simple JS animation Encapsulation

There are also a lot of encapsulated JS animation libraries on the Internet, but most of them are too functional, and as for the large amount of code, thousands of lines are too frequent to be used in small projects. Here we have encapsulated a

Js Code for proportional auto scaling of images

For example. You can use text-align: center; to center. Proportional scaling cannot be solved by using the width and height attributes of the preset . Because the user picture may be very long or wide. I thought about their relationship online and

30 jQuery plug-ins should be used on the website

Of course, you may not be good at it now, but I am sure you will find that they are used in your future projects !. Nivo Slider Undoubtedly, this plug-in is the world's most awesome jQuery slider image with over 15 transition effects. Anything

Implementation Code of jqGrid paging in jQuery

(1) Page code:Copy codeThe Code is as follows: Insert title here Href = "js/themes/basic/grid.css"/> (2) the data in the backend servlet is simulated.Copy codeThe Code is as follows:/*** Servlet implementation class DataServlet*/Public class

Total Pages: 5378 1 .... 2489 2490 2491 2492 2493 .... 5378 Go to: GO

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.