Jquerycookie plug-in code class, you can use this to easily control the cookie, but it feels that you have already used jquery, otherwise it is unnecessary to use such a large js class, you can view the code that was previously improved by the
We all know that an event is used to execute a Function, especially Javascript, when an event (condition) is triggered, it is more important to understand the use of Event in Javascript. Here we will introduce the use of Event in
If simple Nesting is usually enclosed by double quotation marks, single quotation marks are used in the nesting. Otherwise, if you are particularly responsible for nesting, you can refer to the following method. Nesting of quotation marks
The
On 51js, many experts have implemented the 5-Second button implementation method, specially sorted out, hoping to help you. First, give a good code:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to
It seems to be very popular recently. I wrote a js function to implement it.
New Document function stringToDateTime (postdate) {var second = 1000; var minutes = second * 60; var hours = minutes * 60; var days = hours * 24; var months =
Below are some common examples of Javascript's IE and Firefox compatibility
1. document. formName. item ("itemName ")
Note: in IE, you can use document. formName. item ("itemName") or document. formName. elements ["elementName"];
In Firefox, only
In the morning, I did some tests. When I got the page to Firefox, there were a bunch of problems. The page layout was not mentioned. The Javascript code problem was a headache, for example:
1. document. all () does not work in FF. It must be changed
Textbox color changing
JS file:
The Code is as follows:
Function mouseAction (){Var textInputs = document. getElementsByTagName ("input ");Var len = textInputs. length;Var index = 0;Var textInput;/*It can also be traversed using the for in
As mentioned above, the ID selector provides the fastest speed. Therefore, in HTML code, ID can be used instead of class as much as possible.
8. Use ID instead of Class.
As mentioned above, the ID selector provides the fastest speed. Therefore, in
Restrict direct DOM operations
4. restrict direct DOM operationsThe basic idea here is to create what you really want in the memory and then update the DOM. This is not a jQuery best practice, but it must be used for effective JavaScript operations.
Currently, the user avatar function is used in this project. leaders say that it is best for users to choose their Avatar by cropping images after uploading an image. My colleague recommended the Jcrop plug-in to go to its official site. Basically,
Javascript operations on cookie _ Get and modify code are improved with the previous method, and class methods are used.
The Code is as follows:
Function $ Cookie (){Var a = arguments. callee;Var B = a. _ cached;If (a. _ cached) {return a. _
GetBoundingClientRect first test the code
The Code is as follows:
Management System
SCRIPT
Alert (document. getElementById ("w3124"). getBoundingClientRect (). top );
SCRIPT
The following is the alert result.
IE, FF, Chrome: 208
JQuery (1.3.2) 7 lines of code deal with the layer that follows the screen scrolling, the code is very streamlined, very good.
The Code is as follows:
Jquery. text-effects
Although DOM provides the ability to dynamically modify documents, this is not enough for developers. IE4.0 introduces two features for all elements to facilitate document operations. These two features are innerText and innerHTML. The innerText
Remember that when I was in school, for example, to modify the information, the values of some of the values that need to be modified are displayed. The data is first transmitted to the background and then displayed on the foreground, it is really
Window. event. srcElement: Get the code of the event source object. You can refer to the Code sent by the script home before. It is compatible with multiple views.
one advantage is that I want the body (or other elements) some object response
Js usage summary, relatively good, both novice and veteran are good. Js usage summary, relatively good, both novice and veteran are good.
1. Create a script block 1:
It seems very simple to create an instance from an object. Yeah, basically in all languages, Javascript that uses the new Keyword to create an instance is no exception, of course, but have you considered the reference of objects? The common practice
Functions that can be used to run code are similar to those on the website.
Script var userAgent = navigator. userAgent. toLowerCase (); var is_opera = userAgent. indexOf ('Opera ')! =-1 & opera. version (); var is_saf = userAgent. indexOf
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