Szach's avatar
Level 5

document.execcommand(' bold') not working

I am trying to create a content editable div for blog page. In it my document.execCommand(' bold') is not working properly. It sets the font to bold but does not go back to normal if I click the button again. Other buttons such as those for italics etc work properly. Does anyone have a solution for this?

0 likes
4 replies
Szach's avatar
Level 5

@resin Thank you for the link but the answer given is specific to a code written by poster which includes ranges which I am not using. I have looked into a few stackoverflow answers but most of them were mentioning toggling the according to id etc and not specific to use in content editable div and one line inside. I was hoping for a simple solution if anyone had one.

Szach's avatar
Szach
OP
Best Answer
Level 5

I found out what was wrong. It was specific to Laravel. When I looked at developer tools,I saw that the font-weight was based on app.css. Once I disabled app.css, the command is working properly and I can toggle the bold easily inside contenteditable div. Boostrap and other styling will need to done separately since we lose the automatic styling.

Szach's avatar
Level 5

@jeffreyway, there needs to be a way to mark the question answered without clicking best answer on one's own reply.

Please or to participate in this conversation.