Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ejercicio vicente
<input type="text" onkeyup="colorear(this.value)">
<div id="texto">texto 1
<br> texto 2</div>
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;
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.