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

166
Vistas
problem when using javascript to display banner, the banner does not display when using javascript?

I am newbie with javascript and here is my problem.

Here is my code

https://codepen.io/nguyencuc2035/pen/XWVXxxK

As you can see in my code, I wrote a javascript to display a banner named toast at a right conner and here is the code

<script>
        function toast({
            title = '',
            message = '',
            type = 'info',
            duration = 3000
        }) {
            const main = documet.getElementById('toast');
            if (main) {
                const toast = documet.createElement('div');
                toast.classList.add('toast');
                toast.innerHTML = `
                <div class="toast__icon">
                <i class="fa-solid fa-circle-check"></i>
                </div>
                <div class="toast__body">
                <h3 class="toast__title">Success</h3>
                <p class="toast__msg">Import an external stylesheet:</p>
                </div>
                <div class="toast__close">
                <i class="fa-solid fa-xmark"></i>
                </div>
                `;
                main.appendChild(toast);
            }
        }
        toast({
            title: 'Success',
            message: 'Import an external stylesheet:',
            type: 'success',
            duration: 3000
        })
    </script>

Of course in the styles.css I wrote .toast .toast__icon , .toast__body , .toast__close,

But my problem is, when I ran my code, it only display the toast__body and toast__close, not display the toast.

Could you please give me some advice for this problem ? Thank you very much for your time.

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

0

I Fidgeted with your code on Codepen, and it seems you've used documet and not document. You're missing an N.

Remember you have to be really careful with your spellings in JavaScript. If it still doesn't work feel free to reply back. Hope this helped.

And if it helps you can use jQuery to just append the banner. It really simplifies the code as well.

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