Skip to content

Commit 9e9eb7a

Browse files
committed
Find & Replace
1 parent a5d5a2f commit 9e9eb7a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>&#x1F3F4;&#x200D;&#x2620;&#xFE0F; Complete Javascripts Course</title>
8+
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
9+
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
10+
<style>
11+
12+
</style>
13+
</head>
14+
15+
<body>
16+
<br />
17+
<br />
18+
<center>
19+
<!-- <input type="text" id="item"> -->
20+
<br />
21+
<div id="wrapper">&#x1F4C3; &#x1F3EA; 👾</div>
22+
<br />
23+
<div id="message">Complete JavaScript Course</div>
24+
<div id="output">Complete JavaScript Course Complete JavaScript Course Complete JavaScript Course Complete
25+
JavaScript Course Complete JavaScript Course</div>
26+
Search For : <input type="text" id="sText">
27+
Replace With : <input type="text" id="rText">
28+
<input type="button" class="btn btn-outline-warning" onClick="lookUp()" value="Find Text">
29+
<br /><br />
30+
</center>
31+
<script>
32+
var message = document.getElementById("message");
33+
var output = document.getElementById("output");
34+
35+
function lookUp() {
36+
var s = document.getElementById("output").innerText;
37+
var st = document.getElementById("sText").value;
38+
var rt = document.getElementById("rText").value;
39+
var re = new RegExp(st, "ig");
40+
var result = s.match(re);
41+
if (result) {
42+
var rr = s.replace(re, rt);
43+
document.getElementById("output").innerText = rr;
44+
}
45+
console.log(result);
46+
}
47+
</script>
48+
49+
50+
51+
<script src="https://code.jquery.com/jquery-3.5.0.js" integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc="
52+
crossorigin="anonymous"></script>
53+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
54+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
55+
</body>
56+
57+
</html>

0 commit comments

Comments
 (0)