I already have a custom TinyMCE button that returns the selected text using

var selected = tinyMCE.activeEditor.selection.getContent();

However, when a user creates a WordPress "link" like this...


...and the user selects the "Link" text, my selected variable will only contain the word "Link". What I need it to contain is the entire <a>, with the src and target and everything, so that I can parse it and inject a shortcode instead.

I have already tried .getContent({format: 'raw'}); and the result is the same.

How can I get TinyMCE to give me the selected underlying markup as well?

1 Answer 1


I was able to do what I wanted to do by using .getNode() instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.