Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda