请大神帮帮忙看看
javascript吧
全部回复
仅看楼主
level 1
lcde01 楼主
<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;
if (n == 0){ showConut.innerText = null; }
else{ showConut.innerText = n; }
};
document.addEventListener("selectionchange", aa);
</script>
怎么只在id=aa 下选取统计结果呢?
2022年10月29日 07点10分 1
level 6
function aa(event)通过这个event获取你选中区域的元素,然后做一个判断,如果元素id等于aa就执行后续统计
2022年10月30日 07点10分 2
1