I have a button that uses a function with window.find to search/highlight a word.
The issue I am facing is that I am unable to make this search case-sensitive. And if possible I would like to make the search within a specific div.
var myButton = document.getElementById('myButtonId');
myButton.addEventListener('click', function() {findString ('Text',1,0,0,0,0,0)});
function findString (str) {
if (parseInt(navigator.appVersion)<4) return;
var strFound;
if (window.find) {
strFound=self.find(str);
if (!strFound) {
strFound=self.find(str,0,1);
while (self.find(str,0,1)) continue;
}
}
if (!strFound) console.log ("String '"+str+"' not found!")
return;
}
<button id="myButtonId">Find</button>
<div id="myDivId1">
<p>
This is some text in a paragraph.<br>
It has Text placed in my first div.
</p>
</div>
<div id="myDivId2">
<p>
This is some texT in a paragraph.<br>
It has tExt placed in my second div.
</p>
</div>