Skip to content

Commit 1e1093b

Browse files
committed
string method demo
1 parent eab7422 commit 1e1093b

25 files changed

+427
-0
lines changed

string-Method/str-anchor.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.anchor('name'));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-big.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.big());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-blink.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.blink());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-bold.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.bold());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-charCodeAt.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.charCodeAt(0));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-concat.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome';
10+
document.write(str.concat(' to',' China'));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-fixed.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.fixed());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-fontcolor.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.fontcolor('red'));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-fontsize.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.fontsize(-1));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-italics.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.italics());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-link.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.link('http://www.itstrive.com'));
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-localeCompare.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='张三';
10+
var str2='李四';
11+
document.write(str.localeCompare(str2));
12+
document.write(str2.localeCompare(str));
13+
</script>
14+
</head>
15+
16+
<body>
17+
</body>
18+
</html>

string-Method/str-replace.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.replace('welcome','Not welcome')+'<br>');
11+
document.write(str.replace(/\w+/g,'**')+'<br>');
12+
document.write(str.replace(/\w+/g,function(s,index,str){
13+
//s 符合正则匹配出来的项
14+
//index 匹配出来的项在整个字符串中的位置
15+
//str 整个字符串
16+
console.log(s,index,str);
17+
return s+index;
18+
}));
19+
</script>
20+
</head>
21+
22+
<body>
23+
</body>
24+
</html>

string-Method/str-replace2.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
//交换两个单词的位置
10+
var str='boys girls';
11+
document.write(str.replace(/(\w+)\s+(\w+)/,'$2 $1'));
12+
</script>
13+
</head>
14+
15+
<body>
16+
</body>
17+
</html>

string-Method/str-replace3.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.replace('welcome','Not welcome')+'<br>');
11+
document.write(str.replace(/\w+/g,'**')+'<br>');
12+
document.write(str.replace(/\w+/g,function(s,index,str){
13+
//s 符合正则匹配出来的项
14+
//index 匹配出来的项在整个字符串中的位置
15+
//str 整个字符串
16+
console.log(s,index,str);
17+
return s+index;
18+
}));
19+
</script>
20+
</head>
21+
22+
<body>
23+
</body>
24+
</html>

string-Method/str-slice.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
console.log(str.slice(0));
11+
console.log(str.slice(0,-1));
12+
console.log(str.slice(4));
13+
console.log(str.slice(4,9));
14+
</script>
15+
</head>
16+
17+
<body>
18+
</body>
19+
</html>

string-Method/str-small.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.small());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-strike.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.strike());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-sub.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.sub());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>

string-Method/str-substr.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
console.log(str.substr(1)); //->elcome to china
11+
console.log(str.substr(2,5)); //->lcome
12+
console.log(str.substr(2,-1)); //->' '
13+
</script>
14+
</head>
15+
16+
<body>
17+
</body>
18+
</html>

string-Method/str-sup.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='welcome to china';
10+
document.write(str.sup());
11+
</script>
12+
</head>
13+
14+
<body>
15+
</body>
16+
</html>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>无标题文档</title>
6+
<style>
7+
</style>
8+
<script>
9+
var str='Welcome To China';
10+
console.log(str.toLowerCase());
11+
console.log(str.toLocaleLowerCase());
12+
</script>
13+
</head>
14+
15+
<body>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)