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