views:

36

answers:

2

I have a text <info>SOME CONTENTS GOES HERE</info>

How i can remove this text from the editor when I click on a button (custom button) using javascript function. I used this code:

dom.remove(dom.getParent(selection.getNode(), 'info')); 

But it is showing an error. Is there any solution?

Thanks in advance.

+2  A: 

tinyMCE offers a method under DOMUtils which is tinymce.dom.DOMUtils/remove

// Removes all paragraphs in the active editor
tinyMCE.activeEditor.dom.remove(tinyMCE.activeEditor.dom.select('p'));

// Removes a element by id in the document
tinyMCE.DOM.remove('mydiv');

So in your case since you want to remove <info> and what's inside then you should write something like :

// Removes all paragraphs in the active editor
    tinyMCE.activeEditor.dom.remove(tinyMCE.activeEditor.dom.select('info'));
Braveyard
i didnt get any solution
THOmas
@thomas: I edited my answer, hope that helps.
Braveyard
And also this is my Google phrase -- http://goo.gl/NLO6
Braveyard
A: 
var a = ed.selection.getNode();
var txt = ed.selection.getContent();
var newT = document.createTextNode(txt);
a.parentNode.replaceChild(newT, a);
THOmas