I encountered an issue with the string replace method I implemented on my website. Upon checking the page using the web browser on my Android phone, I noticed that it was not functioning as intended. Here's a snippet of the code:
/*The function is supposed to work on page load*/
function changeclr() {
var body = document.getElementById('body').innerHTML;
var all = body.replace(/</g, '<code><').replace(/>/g, '></code>').replace(/</g, '<span style="color:blue;"><</span>').replace(/>/g, '<span style="color:blue;">></span>');
document.getElementById('body').innerHTML = all;
}
code {
color: brown;
}
<div id="body">
<p>Here is an example <li>text</li&></p>
<button type="button" onclick="changeclr()">Try</button>
</div>
Any ideas on why this isn't working on mobile web browsers?