使用jQuery查找DOM中字符串的位置

使用jQuery查找DOM中字符串的位置,jquery,dom,Jquery,Dom,我有以下问题: 我使用jQuery.text()函数获取整个div元素的纯文本内容 现在,在这个字符串中,我创建了一个小的子字符串。 我想回到dom中,找到整个dom中这个子字符串的strpo。 这是JSFIDLE 这是html <body> <div class="geronimo"> this is the problem.<p> now what do i do</p> <p> this is the

我有以下问题:

我使用jQuery.text()函数获取整个div元素的纯文本内容

现在,在这个字符串中,我创建了一个小的子字符串。 我想回到dom中,找到整个dom中这个子字符串的strpo。 这是JSFIDLE

这是html

<body>
       <div class="geronimo"> this is the problem.<p> now what do i do</p>
       <p> this is the next problem<br> i hope someone can help
       <em> im cooked if i dont find a quick solution.</em>
       </div>
我想强调的是,我想要一个可能使用纯DOM方法的解决方案,而不是使用正则表达式。
对于正则表达式,我知道这是可能的,但不建议将正则表达式用于此类工作。

这似乎是一个坏主意,但我知道什么->
$('body').text().indexOf(searchstring)???我不清楚这个问题???我很困惑这很好用,thanks@user2076066-不客气!
     var textlengths = textcontents.length;
    //get a random number inside this length
    //create a searchstring from this
    var searchstring =
       textcontents.substring(Math.floor((Math.random()*textlengths)+1,textlengths));
      alert(searchstring);
     //now find this searchstring in the dom and return its strpos