简体   繁体   English

如何在另一个文本区域中显示文本区域和可编辑 div 中突出显示的文本的 position?

[英]How to show the position of highlighted text in a textarea and editable div, in a another textarea?

Can someone please help to modify the following code to run as simple js function from a button, and show the the highlighted text and its position in another textarea?有人可以帮助修改以下代码以从一个按钮作为简单的 js function 运行,并在另一个文本区域中显示突出显示的文本及其 position 吗? I've tried to use the variables appearing in console.log.我尝试使用出现在 console.log 中的变量。 But it didn't work.但它没有用。 the source of the code 代码的来源

https://stackoverflow.com/questions/60359921/how-to-get-highlighted-text-position-from-textarea

I simply tried to reuse the variable, but it didn't work.我只是尝试重用该变量,但它没有用。 document.getElementById("n3").value = startPos; document.getElementById("n3").value = startPos;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM