単語を 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
ます。助けてください。