//html
textarea id="aa">1,2 /textarea>
textarea id="bb">1,2 /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下选取统计结果
代码不全啊,把全的发我吧,我看看
《textarea id="aa"》1,2,3,4,5,6,7,8,9,0,《/textarea》
《textarea id="bb"》0,9,8,7,6,5,4,3,2,1,《/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);
《/script》
我把<> 换成了《》, 想实现的是只在textarea id="aa" 里面统计