It works on codepen, but doesn't work on my local host using vscode

I am doing a table sort, but I got the code working fine in codepen, but when I post the same code in VScode it doesn’t seem to to work.

I already linked the CSS and JS files to the html page… and it doesn’t work.

I was previously using Bootstrap for style on the table, and deleted all the boot strap classes to see if that was a problem… then I completely open a new folder without any Bootstrap at all, and still doesn’t work.

Why wouldn’t it be working? I am opening it on my localhost.

Below is the codepen link…

and a snip of my vscode…

By the way, I would like to keep using Bootstrap as the site is built with BootStrap5

Also… the code is a sample I found, but I can also re-code it using some other samples from w3 schools… but at this point I don’t understand why a code is working fine on codepen but not working with VScode and my localhost. … its giving me a big headache…

What is not working? The js for sorting? The css styling? Nothing displays?

Did you use the export function in codepen to gen the files for you can then import / copy them into VSC? (That probably would have been easiest)

One thing I’d suggest is moving the call for your .js script to right before the closing body tag. The way the script is written I believe it needs the HTML code to be loaded so it can act on it.
Much the same way as the FCC test script when you did the projects.

Hope that helps.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.