简体   繁体   中英

Html external file links not working with each other

I ran into this problem today, and it took me a long time to see the mistake I did. I had this javascript file I made, and wanted to apply jQuery to it. I placed the <script> link after my js file. It seemed like the jQuery were not applied to the custom js file, even though it should work. I wanted to post this question so beginners wont do this mistake over and over again. Or anyone else.
See answer below.

PS: Maybe someone with good reputation can create a html-links, external-links, links or something like that, because it suits this question.

Ok, so after a long long time, I found the simple mistake I did. This can be a common mistake for beginners, or like me, who just forgot. I placed the jQuery after the custom js. So when the js is compiled, it cant find the jQuery I want to use, because the jQuery comes later in the compilation.

Always place files from the internet, files you didnt make or files that you just want to overwrite with a new file.

For example a css file. If you have a bootstrap file, but want your custom css to overwrite the bootstrap, simply place the css below it. The last css compiled, will be the last to overwrite the ones before it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM