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

391
Vistas
CKEDITOR values show in 1 line in the console log result

I am creating CKeditor function. Now my problem is I cannot get the value in the CKeditor textarea. I try to console log to show the result, it cannot cannot follow html to show like below the picture:

output

Below is my coding:

<textarea id="editor1" name="editor1">This is sample text</textarea>

<script type="text/javascript">
CKEDITOR.replace( 'editor1', {
            height: 300,
           // enterMode: CKEDITOR.ENTER_BR,
            filebrowserUploadUrl: "/eokclaim/app/ajaxfile.php?type=file",
            filebrowserImageUploadUrl: "/eokclaim/app/ajaxfile.php?type=image"
        } );

    function updateDiv(){
       var editorText = CKEDITOR.instances.editor1.getData();
       console.log(editorText);
    }
</script>

I want the expected result in console log are (I want the console log result show in 1 line) :

<p>Picture 1:</p><br /><p><img alt="" src="https://www.abc.com.my/folder/app/uploads/blue-pin.png" style="height:100px; width:100px" /></p><br /><p>Picture 2:</p><br /><p><img alt="" src="https://www.abc.com.my/folder/app/uploads/1.png" style="height:34px; width:100px" /></p>

Hope someone can guide me on how to solve the problem. Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In order to remove line breaks, you can use replace function. Your code would look like :

function updateDiv(){
   var editorText = CKEDITOR.instances.editor1.getData().replace(/(\r\n|\n|\r)/gm, "");
   console.log(editorText);
}

If getData() is returning a string as I think, it should work.

about 4 years ago · Juan Pablo Isaza Denunciar
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