The replace method only works on a string with the first match substring. In the below example, how can I replace all 'a' with 'b'? Thanks in advance for any help!
Code:
<script>
function replaceIt(){
var textStore = document.getElementById("textInput").value;
var newText = textStore.replace("a","b");
alert(newText);
};
</script>
<input value="aaaabbbccc" type="text" id="textInput" name="textInput" />
<button onclick="replaceIt()">Replace all the a with b!</button>