I am developing an application where I am using CKEditor. I have provided a button called clear. Whenever user selects some part of text and clicks on clear button only the selected text should get deleted.
I used the below code in my application but whenever user clicks on clear button not only selected text but whole content gets deleted.
function clear_onclick() {
CKEDITOR.instances.message.setData('');
}
How can I clear the selected text from CKEditor on click of clear button in ASP.Net MVC2?
I am developing an application where I am using CKEditor. I have provided a button called clear. Whenever user selects some part of text and clicks on clear button only the selected text should get deleted.
I used the below code in my application but whenever user clicks on clear button not only selected text but whole content gets deleted.
function clear_onclick() {
CKEDITOR.instances.message.setData('');
}
How can I clear the selected text from CKEditor on click of clear button in ASP.Net MVC2?
Share edited Mar 25, 2013 at 9:15 rouen 5,1342 gold badges26 silver badges51 bronze badges asked Mar 25, 2013 at 6:49 user2031327user20313272 Answers
Reset to default 11This will do the job:
var range = CKEDITOR.instances.editor1.getSelection().getRanges()[ 0 ];
range.deleteContents();
range.select(); // Select emptied range to place the caret in its place.
Try this:
CKEDITOR.instances["textAreaId"].getSelection().getSelectedText().setData('');