How to set background color for some inner text of

2019-05-29 04:42发布

问题:

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.