Home > Blockchain >  Basic JavaScript/JQuery Function Not Working for No Reason
Basic JavaScript/JQuery Function Not Working for No Reason

Time:11-07

My teammate and I have been tirelessly working at this seemingly impossible bug with js/jquery. We have a simple function called feedback in our .js file, but it is not working. See our replit link below:

https://replit.com/join/pryxsdvjtz-5pengoo

Please help.

Edit: Here's the function:

function feedback(event) {
  event.preventDefault();
  console.log("this function ran");
  var text = $('#text');
  console.log(text);
}

I've reduced a lot of its functionality for debugging purposes but all I want it to do is print "this function ran" in the console. Thank you!

CodePudding user response:

This is because I think, replit is not redirecting to create.html which you can verify from the url in the mini browser window. I feel this is how the replIt works. Whereas, if you tried in new tab you can see create.html in the url as a path. If the create.html is not loaded, then your script is also not loaded right. So, your function is not executed.

In the top right corner of the browser preview window in replit there is one option for opening the url in new tab. The code you posted works there. It is not working in the preview-browser-window. So there is nothing wrong with your code.

  • Related