Is there a way to make a text area partially editable? (make only portions of the text editable)

前端 未结 8 1592
太阳男子
太阳男子 2020-11-29 08:09

I just came across a situation in which it would be an elegant solution to have only portions of a text area (previously loaded with text) be editable while other portions a

8条回答
  •  北海茫月
    2020-11-29 09:12

    Interesting idea, but sadly, the text within the text area must be treated uniformly, i.e. you can't disable a subsection of the text area contents.

    You do have options, however. If you can identify the text that needs to be disabled, you can add it as a DOM element (i.e. a div), and then position it in a way that implies it is inside the text area.

    You can imply that this div is inside the text area either by making the text area big and using position: relative/absolute styles to move the div over the text area. Or, you can remove the border on the text area and put it on a container that also contains the div w/ "disabled" text.

提交回复
热议问题