Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!