1
HTML:タグ内のコンテンツを除いた用語を検索して強調表示する方法は?
Our formula is this: We go out, we hit people in the mouth.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9">[9]</a></sup> The team went 5–4 overall
私が一致しようとしている:
in the mouth. The team went
を基本的に私はthis answerからコードを適応してきた<sup>
タグ
内のテキストを無視しようとしています。
document.designMode = "on";
var sel = window.getSelection();
sel.collapse(document.body, 0);
while (window.find(search_string)) {
document.execCommand("backColor", false, "yellow");
}
sel.collapseToEnd();
document.designMode = "off";
これはタグを無視しますが、タグ内のテキストは無視しません。