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

125
Vistas
replace a declared function

I have a small code problem:

I want a already declared function to replace it with another one.

For example, let's say i have a js file, with the function:

function SayHello() {
 $(".nav").addClass('sticky animated fadeInDown');
}

and i want to replace that function with another js file and a function like that:

function SayHello() {
 $(".nav").addClass('fadeUp');
}

The code is just an example, but the point is that I can't change the original js, so i want to just replace what the function does.

Any ideas on how i could do that would be appreciated :)

Thanks.

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

0

There are two main ways to do this.

One is to include a second function definition later down in a script tag.

The second is to set the new function in the window object

window.sayHello = newFooFunction;
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try this

let MyFunction = function SayHello() {
 return $(".nav").addClass('sticky animated fadeInDown');
}

and if u want to replace it

let MyFunction = function SayHello() {
 return $(".nav").addClass('fadeUp');
}

have a good day

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