Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Automatically wrap "div class" around table inside TinyMCE 5

I'm using the TinyMCE 5 editor.

Now I'm trying to find a solution so the editor automatically wraps a table with a certain "div container".

I tried it like that:

tinyMCE.init({
    selector: '#myTextarea',
    plugins: 'table code autolink link lists charmap print preview textcolor code',
    toolbar: 'table code link | undo redo | insert | code',
    menubar: false,
    min_height: 300,
    setup: function (ed) {
       ed.on("keyup", function () {
                var contentmain = tinymce.activeEditor.getContent();
                $('#preview').html(contentmain);
        });
        ed.on("keyup", function () {
            $('.tabledefaultg').wrap('<div class="scroll-bar"></div>');
        });
    }
});

The problem is that <div class="scroll-bar"> doesn't get added inside the editors' source code. It just gets added inside the "preview" container.

How can I fix this problem?

This is the JSFiddle.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!