Help needed


#1

Hi everyone,

I’m currently going through the JQuery course and everything is going really well. However, I’m also working on my personal portfolio and I want to use JQuery on it.

The Type editor that I use is Brackets and for some reason the code just does not work and I have spent the weekend and pretty much a whole day at work today googling on how to make this work.

step 1) I added the script tags that a copied from JQuery.com and pasted it at the bottom of the HTML skeleton right before the body tags on top of the script tag that links to the js file.

step 2) I created a file called main.js, where I wrote the JQuery code.

I also tried the code on CodePen and I know that the code is fine. Just not sure what’s wrong with Brackets :persevere:

Can someone please help?:pray:


#2

We will need to see your HTML to explain the first error on line 2.


#3

Haha , I was hoping it would be you who would come along :star_struck:


#4

Well the code is very long but I took some screen shots to simplify

I made some cards and added some links and the whole idea would be once the mouse enter the card, show the links.

and at the bottom, I added the CDN plus the script tag to the main.js page


#5

The first thing would be to confirm that jQuery is present.

console.log(typeof jQuery)

It should come back as function. If it is undefined then there is a source issue.

As for where we load jQ, it doesn’t matter whether in the HEAD or the BODY since it doesn’t attempt to access the DOM until after main.js fires.


#6

This is what I got back.

To be honest I thought it would be a straight forward thing really. Copy and past the CDN, create a new file .js and add the .

:sweat:


#7

The console.log statement should be typed directly into the browser console, not the editor. Run your HTML code, and click the browser window… Inspect element. Click console tab.

 > typeof jQuery
<- 'function'

#8

You were spot on, It came back undefined. What do I need to do to fix this?


#9

Trace the URL back to the source. Copy it and paste it into the location bar and see if it opens on a JavaScript file. If not, then the URL is incorrect. Go to th code.jquery.com page and select another minified version, say version 2.xx.yy. Right click, copy location, and paste it into your code. You can check first that it does indeed open on a JS file, to be sure.


#10

IT’s becoming so overwhelming that I don’t know what else to do. I mean the same code worked at CodePen but its not working with Brackets.

I really appreciate your help but I don’t understand the last instructions. Which Url do you mean?

file:///Users/raphaelnunes/Desktop/New%20Portfolio/js/main.js
or
file:///Users/raphaelnunes/Desktop/New%20Portfolio/contact.html

How do I check if the url work on a js file?
I’m so confused, sorry. :tired_face:


#11

Use the URL in your script src, the one that points to the jQuery CDN.


#12

I tried different minified versions on my code but nothing changed. I don’t know. :sob:


#13

Oh my god I can’t not believe this but I managed to get it working lolololol…

All I needed was to take out the js/ before main.js on the very last tag before the closing body tag.

Everywhere else I researched, indicated to put the js/ but apparently not. Three full days on this and I finally managed to solve the issue.

Roy, you ara a great asset to this community thank you so much for your time helping me. I really appreciate it. :pray:


#14

You’re very welcome; and, thanks for the compliment.