At the end of the script, add return false; . This will force the page to run the script without redirecting the page.
Edit: (after viewing your version).
Is it better practice to use Jquery or Javascript to do this? How can I do this using either one of them?
jQuery is a javascript library, it doesnβt matter if you use plain javascript or use jquery while you are happy with the result.
And that you say that you have successfully manipulated the page of the redirect page ... I do not see how this is possible.
source share