Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Dviejopomata
Created October 27, 2017 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dviejopomata/acf2635afab7776efe278e6c8d200b09 to your computer and use it in GitHub Desktop.
Save Dviejopomata/acf2635afab7776efe278e6c8d200b09 to your computer and use it in GitHub Desktop.
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