Implementation 1:
CopyCode The Code is as follows:/* Quiet Method */
Function pad (Num, n ){
VaR I = (Num + ""). length;
While (I ++ Return num;
}
The above code is too cool to reflect my real level. So there is implementation 2:Copy codeThe Code
If you have the foundation for programming, it is easy to learn Javascript. If you do not have the foundation for programming, don't worry. We will explain each line for you.
Code.
Copy codeThe Code is as follows:
We will skip the HTML
Events are quite intuitive and commonly used:
Event
Description
Abort
The image cannot be loaded because it is blocked.
Blur, focus
Lose focus and get focus
Change
It is applicable
1. Define the type
CopyCode The Code is as follows: function userobject (parameter ){
}
Parameter can be omitted, which is equivalent to the constructor parameter in C.2. instantiate a custom typeCopy codeThe Code is as follows:
3. Add
The principle is basically like this. If strings are input, convert them into an element node. However, this element node can also have many layers and put the elements to be wrapped in the innermost layer. There are several methods to convert a
Code
Copy codeThe Code is as follows:
Username:
// verify that the display is hidden.
Password: // triggers the onfocus event when the PWD input box gets the focus, verify that the content in the name input box is in the correct format.
Error Mode: syntax error warning
CopyCodeThe Code is as follows: function (){
// Insert code here
}();
Mode 1: function literal)
Declare the function object and then execute it.Copy codeThe Code is as follows: (function (){// Insert code here})(
The for loop is generally used to traverse arrays in Javascript, as shown below:
CopyCode The Code is as follows: var arr = [];
For (VAR I = 0; I // Loop
}
The biggest problem with this kind of code is that the. length is obtained through the.
First, let's look at the common functions of JavaScript.
CopyCode The Code is as follows: function Sum (a, B ){
VaR c = 10;
Function add (){
C ++;
}
Add ();
Return A + B + C;
}
VaR d = sum (4, 5 );
Alert (d) // 20
It can be seen that the external
1. isprototypeof
Isprototypeof is used to determine whether the specified object object1 exists in the prototype chain of another object object2. If yes, true is returned; otherwise, false is returned.
The format is as
First look:
CopyCode The Code is as follows: var objjson = {
OP1: 'objjson option1 ',
Fn1: function (){
Alert (this. OP1)
}
}
In this form of declaration, you can directly access internal attributes through objjson. OP1 or objjson. fn1 (). This is
ArticleDirectory
1. It is named in Java, but it is not Java
2. Is null an object?
3. Nan! = Nan
4. Global Variables
5. All browsers tested as Mozilla User-Agent
6. Inconsistent function range
7. bitwise operators
8. Too
If you want to do the same, you also need my getelementbytagnames () function.
CopyCode The Code is as follows: function createtoc (){
Var y = Document. createelement ('div ');
Y. ID = 'innertoc ';
VaR A = Y. appendchild (document. createelement ('
OK, no nonsense. Implement a javascript timer.
Compared with the Timer class of as3, the function is slightly changed.
Timer2.src. js
CopyCode The Code is as follows :/**
* Timer Model
*
* @ Author rainsilence
* @ Version 2.0
*/
(Function (){
/*
CopyCode The Code is as follows:
JavaScript to obtain client information Copy code The Code is as follows: Document. Write ("Screen Resolution :")Document. Write (screen. Width + "*" + screen. Height)Document. Write (" ")Document. Write ("available
Form instance
This is the strength of a form. Here is a small problem: Because my server does not support it now, forms cannot be submitted. I will print your input and return a false value so that the form is not submitted.
Onsubmit
Code Two
Idea
Suppose you have an online CD rating tool. You want users to view all their favorite CDs. But how do you know how many images a user can view on average? How many fields do you need to add on this page?
Before w3cdom appeared, this was indeed a
ArticleDirectory
Since a range is created
Although we will explain how to useProgramCreate a range object, but we focus on how to convert the user selection range to W3C or Microsoft document range objects.
What is range?
A
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