Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ejercicio vicente
<html>
<body>
<input type="text" onkeyup="colorear(this.value)">
<div id="texto">texto 1
<br> texto 2</div>
<script>
var id = "texto"
var div = document.getElementById(id);
var text = div.innerHTML;
function colorear(search) {
var newText = text.replace(new RegExp(search, 'g'), '<span style="color:red" >' + search + '</span>')
div.innerHTML = newText;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.