//html
<textarea id="aa">1,2</textarea>
<textarea id="bb">3,4</textarea>
<p id="showConut"></p>
//script
var showConut = document.getElementById("showConut");
function aa(){
var selection = window.getSelection().toString();
var n=(selection.split(',')).length-1;
showConut.innerText = n;
};
document.addEventListener("selectionchange", aa);
我想要达到的结果:只在id=aa下选取统计结果
相似问题