単語を 5 回含む文字列があります。hello を選択すると、4 が返されます。
<div id="content">hello hai hello hello hello</div>
選択したテキスト スクリプトの取得
<script>
if(window.getSelection){
t = window.getSelection();
}else if(document.getSelection){
t = document.getSelection();
}else if(document.selection){
t =document.selection.createRange().text;
}
</script>
選択 haiしている場合は、 を返す必要があり1ます。
選択 hello haiしている場合は、 を返す必要があり1ます。助けてください。