JS Add/Remove events in IE and support DOM browsers are: attachevent (add event in IE), detachevent (delete event in IE), AddEventListener (add event in Dom browser), RemoveEventListener (Support for deletion events in the Dom browser).
For example,
The effect is as shown in the figure:
Here is the core code
Copy Code code as follows:
GAME = {
Randomly generating letters
Randletter:function () {
var arrletter = new Array ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
So with this:
Untitled documents name progresstudy Age 22 Career Students
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This is written in a Java-like manner, with
Return to the original, when the style switch, the control back to the page, that is, table.js only control switch style and record operation:
Copy Code code as follows:
new Web project
Option One
Option two
The first step: quoting Table.js
Copy Code code as follows:
Step Two: Define the selected style, such as "active", the ID of the block to which the tab is applied, such as "sidebar", the serial number that is selected by default,
where the Getelementsbyname (name) method is to get all the elements in the page that have the name attribute, but this method is not the same as what the IE is fetching in the standard browser. In IE, the Getelementsbyname (name) method takes the
Function Name:trim
Function Description: Removing the trailing spaces of a string
Creation Date:2004-7-13 15:30
Last Modify by:n/a
Last Modify date:n/a
String.prototype.trim=function () {
Return This.replace (/(^\s*) | ( \s*$)/g, "");
}
Function
"Program Source"
This effect is mainly reflected in the combination of CSS and JavaScript
CSS Code
Copy Code code as follows:
UL, Li {margin:0; padding:0; border:0;}
. shop-rating {
height:25px;
Overflow:hidden;
Zoom:1;
PADDING:2PX
Untitled document
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Here I quote this code not because it is convenient for me to call later, but to find a point I never use the
Js. Encode is encoded in the JS code after the formation of "garbled", this garbled in addition to reading, can still be good execution.
Often in the Web page has JS encryption code decoding method, but because there are escape characters in the
When you use JS to submit data, especially in Chinese, you will often need the string to be submitted for URL encoding. There are several ways to URL-encode strings in JS, Encodeuri,encodeuricomponent, and escape. In many of the code I see, Escape
In JavaScript, everything is an object, a string is an object, an array is an object, a variable is an object, and a function is an object, so it is permissible to [' A ', ' B ', ' C '].push (' d '); The class itself is also an object, and you can
Just infinte students to put forward "more elegant compatibility" in fact, and this problem has a certain connection (we will see later)
In the helper of function in Youa's script library, add a pattern match that supports overloading
Copy
By the way, please indicate:
Lexical scopes: The scope of a variable is determined when it is defined, not when it is executed, that is, the lexical scope depends on the source code, which can be determined by static analysis, so the lexical scope
Here are about 70% of the content from http://www.quirksmode.org/js/this.html, and the other 30% is my own understanding of it and feelings. Hope to help people who need it ...
First, look at a very typical topic about this keyword:
Copy
Inside mentioned "Dom is the UTF-8 of the code, if the JS library is not separate JS file, but included in the DOM, this problem will not appear." However, the separate JS file is not UTF-8 encoding, is Gacou into the UTF-8 encoded DOM, the Chinese
First method:, code comparison professional recommendation
Copy Code code as follows:
The second method:
Of course, we can get the value of the parameters in the background, and then in the foreground JS code to get the value
Like what:
Copy Code code as follows:
Code 1
function Pig () {}
var pig = new Pig ();
Alert (pig instanceof Pig); => true
function Flypig () {}
Flypig.prototype = new Pig ();
var flypig = new Flypig ();
Alert
Let's take a look at the code: (Supports multiple class queries and queries within a range)
Copy Code code as follows:
/*
* Get the element collection based on the element clsssname
* @param fatherid The ID of the parent element,
1) typeof operatortypeof is a unary operator, and the return result is a string indicating the type of the operand. such as: "Number", "string", "Boolean", "Object", "function", "undefined" (can be used to determine whether a variable exists).
But
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