For most developers, the This keyword of JavaScript can cause a lot of trouble. Because JavaScript does not have a strict class model for languages such as Java, this point in the code is not clear unless you are dealing with callbacks.
In general,
1. Event handlers as HTML property values
HTML code
2. Event handlers as JavaScript properties
Web Teaching Network
HTML code
Description: May be misled by the first method, and you will feel that it should be written as:
Pure JS Code
The code is as follows
Copy Code
/*** Back to the top of the page* @param acceleration acceleration* @param time interval (ms)**/function gotop (acceleration, time) {Acceleration = Acceleration | | 0.1;Time =
The code is as follows
Copy Code
New_element=document.createelement ("script");New_element.setattribute ("type", "Text/javascript");New_element.setattribute ("src", "a.js");//Introducing a.js hereDocument.body.appendChild
Usually we have the following requirements:
First step:
We can define a method: (return directly to the parser only with someone's call)
The code is as follows
Copy Code
function Parsexml (file) {Try//internet
11 digits starting with cell phone number 13
The code is as follows
Copy Code
function F_mobilcheck (as_sourcestring){if (As_sourcestring.match (/^13[0-9]{9}$/g)) return true; 11 digits starting with cell phone number
There are generally three ways to define a function in javascript:
Functions keyword (function) statement:
The code is as follows
Copy Code
function Fnmethodname (x) {alert (x);}
Functions literal (function
Conditional operatorJavaScript also contains conditional operators that assign values to variables based on certain criteria.
GrammarVariablename= (condition)? value1:value2
Example Two
finding the Absolu Te value
GrammarThisThis.propertyOften get used to scripts that are specified in a function through an entire object, such as those contained in a form or method.
Take a look at this instance
Using This in passing form informationThis is some text in I
In Web effects, use the new operator or a predefined constructor, such as
Object (), Date (), Function (), and so on, can all create and initialize a new JS
Object.
The constructor has the following two attributes, the essence of which is still
The WITH keyword for web effects, with statements intended to provide a namespace-style sketch for progressive object access. That is, in the specified code area, the object is invoked directly through the node name.
With (object) {Code}
a
Tip: you can modify some code before running Buyer Center Seller CenterPending orders (10) Transaction to be evaluated (10) Order to be confirmed (10)The purchase quota for this month is 17826.35 RMB (20 RMB)This year's purchase quota of 17826
Tip: you can modify some code before running Firefox-break-word If there were less sympathy in the world, there wocould be less trouble in the world. (o. wilde) 1. (IE browser) continuous English characters and Arabic numbers, use word-wrap:
Tip: you can modify some code before running How JavaScript controls vertical center of div How JavaScript controls vertical center of div 111cn.netChina WEB first stop Tip: you can modify some code before running
The code is as follows:Copy code Javascript:// Prompt plug-in$. Tips = function (ele, txt ){// ParametersVar r = true, // return value of the plug-inWrap = $ (' '), // required package elementAnimationTime = 600,_ This = this, // this ;//
This is just a chain operation. But under firbug, we can see that the returned jQuery object is an array/class array. I don't know how to implement this ..K. fn. prototype = new Array () is not allowed. It seems a little tiring to look at jQuery
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