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

838
Vistas
Is using $ = jQuery; within jQuery( window ).on( 'load', function() { okay?

As $ is undefined in a jQuery( window ).on( 'load', function() { I use $ = jQuery; at the top of this code block and then I can use $ rather than typing jQuery wherever I want to use it like this:

jQuery( window ).on( 'load', function() {

    $ = jQuery;
    var test123 = $( '#test123' );

});

However I have seen on some websites I use this code on it sometimes can throw a Uncaught TypeError: Assignment to constant variable. message occasionally in the console.

Should I be using this method or is there a better alternative to use $ over jQuery

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

0

You can wrap it inside a try-catch.

try{
    window.$ = jQuery;
}catch(e){};
$(window).on('load', function(){
    var test123 = $('#test123');
});
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