Home > Web Front-end > JS Tutorial > js usage methods and functions summary_javascript skills

js usage methods and functions summary_javascript skills

PHP中文网
Release: 2016-05-16 18:53:00
Original
1227 people have browsed it

A summary of how to use js is quite good. It is good for both novices and veterans.

1 Create script block
1:
2 Hidden script code
1:
Relevant code will not be executed in browsers that do not support JavaScript
3 Displayed when the browser does not support it
1:
4 Link to external script file
1:
5 Comment script
1: // This is a comment
2: document.write("Hello"); // This is a comment
3: /*
4: All of this
5: is a comment
6: */
6 Output to browser
1: document.write("Hello");
7 Define variables
1: var myVariable = "some value";
8 String addition
1: var myString = "String1" "String2";
9 characters String search
1:
10 String replacement
1: thisVar.replace("Monday","Friday");
11 Format string
1:
12 Create array
1: < ;script language="JavaScript">
2:
11:
13 Array sorting
1:
14 Split string
1:
15 Pop-up warning message
1:
17 Define function
1:
27 Dynamically output HTML
1:
28 Output newline
1: document.writeln("a");
2: document.writeln("b");
29 Output date
1:
31 Set date output format
1:
32 Read URL parameters
1:
Do you still think HTML is stateless?
33 Open a new document object
1:
34 page jump
1:
35 Add web page loading progress window
1:
2:
3:
6: The Main Page
7:


8:
9:

This is the main page


10:
11:

36 Read image attributes
1:
2: Width
3:
37 Dynamically loading images
1:
38 Simple image replacement
1:
7: 8: onMouseOut="document.myImage.src = defaultImage.src;">
9:
39 Randomly display images
1:
40 Image replacement implemented by function
1:
14:
15: onMouseOut="document.myImage1.src = rollImage1[source].src;"> ;
16:
17:

41 Create slideshow
1:
19:

20:
21:
42 随机广告图片
1:

43 表单构成
1:

2:
3:
7:

8:
9:

44 访问表单中的文本框内容
1:

2:
3:

4: Check Text Field
45 动态复制文本框内容
1:

2: Enter some Text:

3: Copy Text:
4:

5: Copy Text Field
46 侦测文本框的变化
1:

2: Enter some Text:
3:

47 访问选中的Select
1:

2:
7:

8: Check Selection List
48 动态增加Select项
1:

2:
6:

7:
49 验证表单字段
1:
9:

10: Text Field:
11:

12:

50 验证Select项
1: function checkList(selection) {
2: if (selection.length == 0) {
3: window.alert(“You must make a selection from the list.");
4: return false;
5: }
6: return true;
7: }
51 动态改变表单的action
1:

2: Username:

3: Password:

4:
5:
6:
7:

52 使用图像按钮
1:

2: Username:

3: Password:

4:
5:

6:
53 表单数据的加密
1:
18:

19: Enter Some Text:
20:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template