This is a little example how to replace all matches with replace.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<!DOCTYPE html> <html> <body> <p>Click the button to replace "i" with "X" in the paragraph below:</p> <p id="demo">Visit Microsoft!</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var str = document.getElementById("demo").innerHTML; var res = AllReplace(str,"i", "X"); document.getElementById("demo").innerHTML = res; } function AllReplace(str,find,replace){ while(str != str.replace(find,replace)){ str = str.replace(find,replace); } return(str); } </script> </body> </html> |
Click the button to replace "i" with "X" in the paragraph below:
Visit Microsoft!
You’re so awesome! I don’t believe I’ve read through a single thing like that before.
So good to discover another person with unique thoughts on this
topic. Seriously.. thank you for starting this up.
This website is something that’s needed on the internet, someone
with a little originality!