Reputation: 708
I have problem with tinymce in wordpress. I need to put inside tinymce element . In tinymce editor where are two tabs "Visual" and "HTML". When I use my code in "HTML" its works. But when I want to use in "Visual" its not working...
I was trying like this:
JavaScript
function insert_tag(text){
var cont = document.getElementById('bbp_topic_content');
cont.value += '<div>' + text + '</div>';
}
HTML
<a onclick="insert_tag('HELLO')" >Insert text</a>
Any help please ?
Upvotes: 2
Views: 2230
Reputation: 146191
You may try this
function insert_tag(text){
if(tinyMCE && tinyMCE.activeEditor)
{
tinyMCE.activeEditor.selection.setContent('<div>' + text + '</div>');
}
return false;
}
Also use return
in your a
tag
<a onclick="return insert_tag('HELLO')" >Insert text</a>
Upvotes: 7