javascript を使用してテキストの強調表示オプションを使用しようとしています。文字列の開始位置を見つける方法は知っていますが、強調表示するにはどうすればよいですか。私のコードは次のようになります
<div id="entity">health insurance</div>
<div id="article">This kind of insurance is meant to supplement health insurance for cancer-care costs. But generally you're better off putting your money toward comprehensive health policies. </div>
そして私がそれを使ったjavascript
$(document).ready(function()
{
var test=document.getElementById('article').innerHTML;
var variable=document.getElementById('entity').innerHTML;
alert(test.search(new RegExp(variable, "i")));
});
これにより、文字列の開始位置が警告されます。