Created
October 27, 2017 19:06
-
-
Save Dviejopomata/acf2635afab7776efe278e6c8d200b09 to your computer and use it in GitHub Desktop.
Ejercicio vicente
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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