Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
Can't select TinyMCE HTML elements

Please check this JSFiddle.

The <div id="wp-post_content-editor-container" ..> on line 1 and <textarea class="wp-editor-area input-text-area" ..></textarea> on line 108 are the only HTML element I can select (with document.querySelector() or document.getElementById()). The rest give me null .

Why is that? And how can I get the HTML element from TinyMCE?

My goal is to set an event listener in an element inside the <iframe> tag on line 8.

UPDATE:

I use this command to select the HTML element:

let divContentEditor = document.querySelector('#wp-post_content-editor-container');
let divMceu7 = document.querySelector('#mceu_7');
            
console.log('prints the html element');
console.log(divContentEditor);
console.log(divMceu7);

As you can see I print the result on the console, but here is what I got:

enter image description here

When I select the <div id="mceu_7" ..> it's give me null.

My goal is actually to get the element body[id="tinymce"] > p inside the <iframe> tag. You can see it on jsFiddle that I attached on line 97. And then put an event listener for word counters.

const inputTextArea = document.querySelector('body[id="tinymce"] > p');
const wordCount = document.getElementById("word-counter"); // I put this element right below the tinyMCE text area
if (textArea && wordCount) {
    inputTextArea.addEventListener('input', () => {
        const txt = inputTextArea.value.trim();
        wordCount.textContent = txt.split(/\s+/).filter((item) => item).length;
    });
}

But since I can't even select the #mceu_7, I can't select the element deeper than that. It gives me null.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda