请教各位大神 getSelection()选中的问题
javascript吧
全部回复
仅看楼主
level 1
lcde01 楼主
//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下选取统计结果
2022年10月29日 10点10分 1
level 3
我新建了个前端萌新互助群!都是萌新阶层大家都开始学!没有卖课!没有广告!
群号:235419843
大家一起来学习呀!
2022年11月04日 02点11分 2
1