Widget:Highlight: Difference between revisions

From Rangjung Yeshe Wiki - Dharma Dictionary
Jump to navigation Jump to search
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
Line 1: Line 1:
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="/skins/BuNay/resources/jquery.highlight-3.js"></script>
<script src="/skins/BuNay/resources/jquery.highlight-3.js"></script>
<script> $(document).ready(function() { $('body').highlight('<!--{$term}-->'); }); </script>
<script>  
function highlight('<!--{$term}-->') {
var inputText = document.getElementById("firstHeading");
var innerHTML = inputText.innerHTML;
var index = innerHTML.indexOf(text);
if (index >= 0) {
innerHTML = innerHTML.substring(0,index) + "<span class='highlight'>" + innerHTML.substring(index,index+text.length) + "</span>" + innerHTML.substring(index + text.length);
inputText.innerHTML = innerHTML;
}
}
</script>

Revision as of 16:24, 17 June 2021

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script src="/skins/BuNay/resources/jquery.highlight-3.js"></script> <script> function highlight() { var inputText = document.getElementById("firstHeading"); 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; } } </script>