JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">
    I have the magic string <br/> "AbraKadabra"
</div>

CSS

#test{
    height: 200px;
    background: lightgray;
    margin-top: 800px;
}

JavaScript

var givenString = "AbraKadabra";

var matches = $('body, body *').
            addBack().
            contents().
            filter(function(){                     
                return this.nodeType === 3;
            }).
            filter(function(){
            // Only match when contains given string anywhere in the text               
                 if(this.nodeValue.indexOf(givenString) != -1)
                   return true;
            }).first();

if(matches.length > 0){
    var offset = $(matches).wrap('<span>').parent().offset().top;
    console.log(offset);
    $('html, body').animate({scrollTop: offset}, 'slow');
}