- JavaScript 함수 highlight()
예시
<div id="inputText">
Hello World hello
</div>
<script>
function highlight(obj, needle) {
var re = new RegExp(needle, 'gi');
obj.innerHTML = obj.innerHTML.replace(re, function(str) {return '<span style="background:yellow">'+str+'</span>'});
}
highlight(document.getElementById("inputText"), "he");
</script>