Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1051923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:00:43+00:00 2026-05-16T17:00:43+00:00

I am creating plugin for TinyMCE and I need to wrap existing elem (node)

  • 0

I am creating plugin for TinyMCE and I need to wrap existing elem (node) with new one.

For example, if I have paragraph:

<p>hello</p>

after command I need:

<div id="someid"><p>hello</p></div>

I tried below but it doesn;t wrap paragraphs, only theirs body, for example:

tinyMCEPopup.editor.execCommand('mceReplaceContent',true,'<div id="someid">{$selection}</div>')

creates:

<p><div id="someid">hello</div></p>

What is the easiest way to do it?

Update:

Finaly I decided to use below construction (no jQuery):

// Get instance of the editor       
var ed = tinyMCEPopup.editor;

// we are collecting <p> or other default tag to cover it       
var node = tinyMCEPopup.editor.selection.getNode();

// create new dom objects   
var newNode =  ed.dom.create('div', {'class' : 'accordionContent'}); 
var newHNode =  ed.dom.create('h2', {'class' : 'accordionTitle'},document.forms[0].title.value);

// dom modifications
ed.dom.add(node.parentNode, newHNode);
ed.dom.add(node.parentNode, newNode);
newNode.appendChild(node);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:00:44+00:00Added an answer on May 16, 2026 at 5:00 pm

    If you are able to use jQuery in your application there is a wrap() function. If you had

    <div id="someid">hello</div>
    

    Then you could do:

    $('#someid').wrap('<p />')
    

    Gives you:

    <p><div id="someid">hello</div></p>
    

    Update:

    Have read your question again and I think you may need wrapInner() instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are creating an excel plugin but need some guidance as we're new to
I'm creating a new plugin for TinyMce. However I cannot find any examples to
I'm creating a plugin for wordpress and I need to check if a post
I am creating a plugin for Sonar and I need to create a custom
I'm working on creating my first plugin for rails. I'm still pretty new to
I have the following problem: I am creating a simple plugin jquery carousel, to
I am using the Grails ajaxflow plugin for creating a basic wizard. One issue
I need to customize iReport sources.. (not creating plugin) Currently i am using iReport
I'm creating a plugin project that will have a menu and toolbar item, that
I am creating a plugin and got something problems: in the case: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.