9

I am storing some HTML in a variable. Now I want to remove some div tags from this variable: editor_data:

function validate_step_3()
{
    var editor_data = CKEDITOR.instances.editor1.getData(); 
    var i = $(editor_data);
    alert(i);
}

The alert shows:

[object Object]

I want to remove this div

editor_data.find('#fetch_InCkeditor').remove();
5
  • possible duplicate of How to use jquery in a string? Commented May 16, 2013 at 7:53
  • I think it is not resolveable question. Commented May 16, 2013 at 8:04
  • Can you tell us how you store and what you store Commented May 16, 2013 at 8:23
  • It depends on what you do with the variable afterwards. The duplicate shows how to remove the element, but remember that the original string will not change automatically; you have to convert the DOM elements back to HTML. Commented May 16, 2013 at 8:51
  • Hi Chamika, I am storing html throw CKEditor, get input and store it in a variable editor_data , then I want to remove a div tag in this variable. Commented May 16, 2013 at 10:53

2 Answers 2

16

$(editor_data).find('#fetch_InCkeditor').remove(); will do. :)

Sign up to request clarification or add additional context in comments.

2 Comments

At my end i'm able to remove. And $('#fetch_InCkeditor').remove(); will work as well.
I think in stackoverflow.com/a/14756843/1145706 they found the answer. The important thing is to clone the variable before removing things.
0

id on a page is supposed to be unique.

So in this case just this should be sufficient $('#fetch_InCkeditor').remove();

1 Comment

but html data is save in variable, my question is how I find this div in variable and then remove it.thanks

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.