-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.html
46 lines (46 loc) · 1.19 KB
/
string.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<script>
function test1(){
var str="test"+
"1";
var t = document.getElementById("text1").value;
var res=t.includes(str);
if(res){
alert("字符串: "+t+"存在");
}else{
alert("字符串: "+t+"不存在");
}
}
function test2(){
var str="test2";
var t = document.getElementById("text2").value;
var res=t.startsWith(str);
alert(res);
}
function test3(){
var str="test3";
var t = document.getElementById("text3").value;
var res=t.endsWith(str);
alert(res);
}
function test4(){
alert('x'.padStart(7,'abcdefg'));
}
</script>
<body>
<input id="text1" type="text">
<input type="button" onclick="test1()" value="button1"><br><br>
<input id="text2" type="text">
<input type="button" onclick="test2()" value="button2"><br><br>
<input id="text3" type="text">
<input type="button" onclick="test3()" value="button3"><br><br>
<input type="button" onclick="test4()" value="button4">
</body>
</html>