只要给div设置 contenteditable="true" ,div就可像input文本框一样获取到光标啦,代码如下:
html:
<div contenteditable="true"></div>
css:
div{ width:90%; border:1px solid #EBEBEB; min-height:24px; background-color:#FFF; border-radius:5px 5px; overflow-y:auto; font-size:0.9em;}
来源:CSDN
作者:Nikita_jg
链接:https://blog.csdn.net/Nikita_jg/article/details/76214064