-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1m.html
23 lines (22 loc) · 799 Bytes
/
1m.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 157</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 Strings</h1>
<h2>The replaceAll() Method</h2>
<p>ES2021 introduced the string method replaceAll().</p>
<button onclick="changeText()">Try it</button>
<p id="target"></p>
</body>
<script>
let txt = "I love cats. Cats are very easy to love. Cats are very popular.";
txt = txt.replaceAll("Cats", 'Dogs');
txt = txt.replaceAll("cats", 'dogs');
document.getElementById('target').innerHTML = txt;
</script>
</html>