Getting selected (highlighted) html from the Visual Editor on Edit Post page?

So I understand that the visual editor uses something called TinyMCE. How do I retrieve the html that the user selects from the visual editor? I am basically trying to create a button that gets the selected html and replaces it.

Related posts

Leave a Reply

1 comment

  1. The visual editor (TinyMCE) has its own API and since its a JavaScript Based editor you can get the selection using JavaScript very easily

    tinyMCE.activeEditor.selection.getContent();