How to set background color for some inner text of HTML textarea element?

北城余情 提交于 2019-12-22 18:37:16

问题


It looks like selected some text, but the background color will not disappear when you click it or move cursor.


回答1:


You can't use textarea element for this. Just make a contentEditable contentEditable div and use javascript to style it.




回答2:


It may be a div with contentEditable set to true




回答3:


That could be a div the styled during events and as other suggested make it contentEditable. With regards to textarea I have read similar question here. Check it if it's what your looking for.



来源:https://stackoverflow.com/questions/5470671/how-to-set-background-color-for-some-inner-text-of-html-textarea-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!