Set to bold the selected text using tags

前端 未结 2 1063
梦毁少年i
梦毁少年i 2021-01-06 07:30

I have been working trying to make a simple text editor, and have been experimenting with tags. I have been able to create justifying using tags. Now I\'m adding a bold opti

2条回答
  •  我在风中等你
    2021-01-06 07:59

    Tag attributes belong to the tag, not to the text. So, when you highlight something then apply attributes to the "sel" tag, it only affects text that has the "sel" tag. When you remove the tag (by unhighlighting), the attributes revert to the default (or to any other tags that might be present).

    To make text bold, you must create a tag that has the bold attribute and assign that tag to the text. As long as the text has that tag, it will have the attributes of that tag.

提交回复
热议问题