HELL CAMPERS
I have this JQuery block of code that I am sure it works because I implemented it on codepen and it works. The problem is I don’t know how to implement/link/reference (sorry I don’t even know the right grammar for that but I hope someone understands) it on vscode (like you do with css and js).
PLEASE help with the steps I need to follow to get the jquery code to run on my html file
Thanks
jquery is a javascript library
put your jquery code in a js file, and link that in your html plus above that, import the jquery library
Put this tag into your html head, ABOVE the link to your own script:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
This link explains it further: https://www.w3schools.com/jquery/jquery_get_started.asp
I have tried it but its not working…
Don’t know what I’m doing wrong.
Can you share your code? Otherwise it’s difficult to help.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="user-scalable=0, width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Belle & Carrie Rehabilitation Yoga Web Template</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="myown-template.js"></script>
<link rel="stylesheet" type="text/css" href="myown-template.css">
<script src="https://kit.fontawesome.com/298723f7b0.js" crossorigin="anonymous"></script>
</head>
The jquery file is in the js file.
This looks like you’ve got the correct script tags.
Is myown-template.js
in the same folder as your index.html
, or in a subfolder somewhere?
If it’s in a subfolder, you need to change your src
attribute to the correct path:
src="mySubfolder/myown-template.js"
Does you myown-template.js
do anything at all , or does it just complain about unknown jQuery Syntax?
You can test that if you console.log
something in your myown-template.js
file.
console.log('test')
for example. Do you see it logged in your browser console?