-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1l.html
23 lines (22 loc) · 832 Bytes
/
1l.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<title>JS Tutorials 156</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>JavaScript String Methods</h1>
<p>Replace all occurences of "Microsoft" with "W3Schools" in the paragraph below:</p>
<button onclick="changeText()">Try it</button>
<p id="target">Please visit Microsoft and Microsoft!</p>
</body>
<script>
function changeText() {
let txt = document.getElementById("target").innerHTML;
console.log(txt)
document.getElementById('target').innerHTML = txt.replace(/Microsoft/g, "W3Schools");
}
</script>
</html>