This is a simple example of a text editor built using JavaScript's execCommand
for basic text formatting and manipulation.
- Text Formatting: Includes options to make text bold, italic, underline, remove formatting, and more.
- Heading Styles: Apply H1, H2, and H3 heading styles to the selected text.
- Text Alignment: Align selected text to the left, center, or right.
- Text Animation: Demonstrates a simple text animation effect.
- Copy Text: Allows copying selected text to the clipboard
Visit the live demo to see the text editor in action.
The editor uses the execCommand
method to apply text formatting and other commands to the selected text within the contenteditable element. JavaScript is used to manage button clicks and execute the appropriate execCommand
based on the user's actions.
Please note that execCommand
is now considered deprecated and has limitations in modern browsers. It is recommended to explore alternative methods and libraries for rich text editing.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.