I have this HTML piece.
<div class="text">helloworld</div>
So I would like to search the class "text" for a specific string, when that string is found in that class. Do a function, but only if the string was found, if the string wasn't found simply print console.log('not found.')
and if it was simply print that it was.
My code is shown below.
var timerVar = setInterval (function() {DoMeEverySecond (); }, 2000); // << set to 2 seconds.
function DoMeEverySecond ()
{
var xpathResult = document.evaluate("(//text()[contains(., 'helloworld')]) [1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
var node=xpathResult.singleNodeValue;
if (node==null)
console.log('Not found')
else
console.log('found');
}
This code works, but it searches all classes. I would like to only search the class "text"