在我们使用contenteditable编辑时,有时需要光标位置的信息。

 

<div contenteditable="true" style="min-height: 200px; width: 100%;-webkit-user-select: auto"></div>

 

<script>

   if(s.anchorNode.parentElement.localName == 'div'){
      actClass = s.anchorNode.className;
   }else{
      actClass = s.anchorNode.parentElement.className;
   }

</script>

 

这段js代码可以一直监听光标位置信息。

相关文章:

  • 2022-12-23
  • 2021-05-30
  • 2021-10-03
  • 2022-01-14
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-05-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案