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

223
Vistas
how to bring highlight js into pre tag in a whole angularjs application?

I have an angularjs app for students to learn it includes so many html pre tags and code snippets in it. It have highlight js but some of the syntaxes aren't showing exact colours. but i have added window.onload function in one of the usecases and it works, properly. the thing i want ; is to apply it globally on all pre tags but it didn't work with jquery code i've written. to more reference I'm adding both codes and image here

working model working model

on other use cases

on other use cases

code i've added which giving result

window.onload = function() {
                var aCodes = document.getElementsByTagName('pre');
                for (var i=0; i < aCodes.length; i++) {
                    hljs.highlightBlock(aCodes[i]);
                }
            };

code i've tried (if it works i'll make it global)

$("pre").on("load", function() {
                setTimeout(function () {
                    var aCodes = document.getElementsByTagName('pre');
                    for (var i=0; i < aCodes.length; i++) {
                        hljs.highlightBlock(aCodes[i]);
                    }
                },1000)
            })

what i'm missing? is there any other ways to solve this

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