首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >请教 getSelection()选中的问题?

请教 getSelection()选中的问题?

提问于 2022-10-29 18:35:59
回答 0关注 0查看 79

//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下选取统计结果

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档