File tree Expand file tree Collapse file tree
Example/01 Lecture_Example/Basic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+ </ head >
8+ < body >
9+ < script >
10+ // length
11+ // character at the specified index
12+ // index of the first occurrence of a substring within the string
13+ // slice(start, end)
14+ // toUpperCase
15+ // toLowerCase
16+ // replace(searchValue, replaceValue)
17+ // split(separator, limit)
18+
19+ function replace_01 ( ) {
20+
21+ data = document . getElementById ( "t_data" ) . value ;
22+ old = document . getElementById ( "old" ) . value ;
23+ new_Data = document . getElementById ( "new_d" ) . value ;
24+
25+
26+ //new_data = data.replace(old, new_Data);
27+ new_data = data . replaceAll ( old , new_Data ) ;
28+
29+ document . getElementById ( "data_print" ) . innerHTML = data ;
30+ document . getElementById ( "New_print" ) . innerHTML = new_data ;
31+
32+
33+
34+
35+ }
36+
37+
38+ </ script >
39+
40+
41+ < input type ="text " id ="t_data ">
42+ < label > Old word</ label > < input type ="text " id ="old ">
43+ < label > new word</ label > < input type ="text " id ="new_d ">
44+ < button onclick ="replace_01() "> Replace</ button >
45+
46+ < h1 > Data : < span id ="data_print "> </ span > </ h1 >
47+ < h1 > Update Data : < span id ="New_print "> </ span > </ h1 >
48+
49+
50+ </ body >
51+ </ html >
You can’t perform that action at this time.
0 commit comments