4

If I use the execCommand method to highlight the selected text:

document.execCommand("HiliteColor", false, colour);

as it is suggested in this page, and then I want to come back and cancel the highlight format (that is, to return to the situation as it was before I highlighted some text), what could I do?

Community
  • 1
  • 1
tic
  • 4,009
  • 15
  • 45
  • 86

1 Answers1

5

The following will remove formatting:

document.execCommand("RemoveFormat", false, null);
Tim Down
  • 318,141
  • 75
  • 454
  • 536