-
Notifications
You must be signed in to change notification settings - Fork 63
string: replaceAll() Code (JavaScript Pattern Programs) #1127
Copy link
Copy link
Open
Description
/*
string: replaceAll() Code (JavaScript Pattern Programs)
*/
JavaScript Pattern Programs - Sumit Tiwari (SoftEthics)
Replacing Text with replaceAll()
<label for="inputText">Enter some text:</label><br>
<textarea id="inputText" rows="4" cols="50">Visit sitseducators. At sitseducators you will get exciting content to explore.</textarea><br><br>
<label for="oldText">Enter text to replace:</label><br>
<input type="text" id="oldText" value="sitseducators"><br><br>
<label for="newText">Enter new text:</label><br>
<input type="text" id="newText" value="SoftEthics"><br><br>
<button onclick="replaceText()">Replace Text</button>
<p id="outputMessage"></p>
<script>
function replaceText() {
let text = document.getElementById('inputText').value;
let oldText = document.getElementById('oldText').value;
let newText = document.getElementById('newText').value;
let replacedText = text.replaceAll(oldText, newText);
document.getElementById('outputMessage').textContent = "Replaced text is: " + replacedText;
}
</script>
---------*****---------
(JavaScript Pattern Programs)
Get it on Google Play
https://sfet.in/JavaScriptPatternPrograms
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels