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

84
Vistas
Manipulating the output of variables in Django with JavaScript function

I use this piece of code to grab part of the description from video object:

        <div id="description">
            <p>{{video.description | slice:":20" }}</p>
            <button onclick="showDescription()">Show description</button>
        </div>

There I got showDescription() function, I want it to display the rest of the description by changing the inner HTML code:

function showDescription() {
    var text = document.getElementById('description')
    text.innerHTML = "<p style='overflow-wrap: break-word; width: 100%;'>{{video.description}}</p>"
};

But it returns

{{video.description}}

Instead of actual description, any thoughts?

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

0

You need to pass {{video.description}} as a function argument.

<div id="description">
    <p>{{video.description | slice:":20" }}</p>
    <button onclick="showDescription('{{video.description}}')">Show description</button>
</div>

function showDescription(description) {
    var text = document.getElementById('description')
    text.innerHTML = "<p style='overflow-wrap: break-word; width: 100%;'>" + description + "</p>"
};
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