Widget:Highlight: Difference between revisions

From Rangjung Yeshe Wiki - Dharma Dictionary
Jump to navigation Jump to search
((by SublimeText.Mediawiker))
Tag: Replaced
((by SublimeText.Mediawiker))
Line 5: Line 5:
var index = innerHTML.indexOf(text);
var index = innerHTML.indexOf(text);
if (index >= 0) {  
if (index >= 0) {  
innerHTML = innerHTML.substring(0,index) + "<span class='highlight'>" + innerHTML.substring(index,index+text.length) + "</span>" + innerHTML.substring(index + text.length);
innerHTML = innerHTML.substring(0,index) + "<span class='mark'>" + innerHTML.substring(index,index+text.length) + "</span>" + innerHTML.substring(index + text.length);
inputText.innerHTML = innerHTML;
inputText.innerHTML = innerHTML;
}
}

Revision as of 12:50, 13 September 2021

<script> function highlight(text) { var inputText = document.getElementById("bodyContent"); var innerHTML = inputText.innerHTML; var index = innerHTML.indexOf(text); if (index >= 0) { innerHTML = innerHTML.substring(0,index) + "" + innerHTML.substring(index,index+text.length) + "" + innerHTML.substring(index + text.length); inputText.innerHTML = innerHTML; } } window.onload = highlight(""); </script>