This commit is contained in:
Karan 2021-11-25 20:00:31 +05:30 committed by GitHub
parent 5de3cad605
commit 2bcd270607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,34 +0,0 @@
<!doctype html>
<html>
<head>
<title>Complete JavaScript Course</title>
</head>
<body>
<div id="output">Complete JavaScript Course</div>
Search for :
<input id="sText" type="text">
<br> Replace with :
<input id="rText" type="text">
<br>
<button>Replace</button>
<script>
const output = document.getElementById("output")
const findValue = document.getElementById("sText");
const replaceValue = document.getElementById("rText");
document.querySelector("button").addEventListener("click", lookUp);
function lookUp() {
const s = output.textContent;
const rt = replaceValue.value;
const re = new RegExp(findValue.value, "gi");
if (s.match(re)) {
let newValue = s.replace(re, rt);
output.textContent = newValue;
}
}
</script>
</body>
</html>