Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

jQuery

hello guys, at the moment i'm working in jQuery and everytime i run the program an error occurs. "$ is not definet" ... what's the solution for this...? Thanks guys!

Have you added jQuery files?

i added to the html with the script tag

Do you have the correct file path in the script tag? If it's in another folder, you have it pointed correctly to that folder?

Yeah bro. i double checked 0ne thousand times. the only error in console is the one with $ is not defined .i mean why is not defined? actually it should be define like a variable or what?

thank you so much! now is working properly!

1 Answer

Hello Daniel,

There is a Simple Step To Resolved Why jQuery ( $ ) is not defined.

Step one :

Check That jQuery Script Source is Found and Working Properly

Step Two :

Try Testing Code , Is it work for long hand jQuery instead of short hand dollar sign :

jQuery(document).ready(function(){
 alert("jQuery is working properly");
});

If the above code is working, It usually due to the fact, That some other libaries such as Libaries in Wordpress are take over the short hand dollar sign which make the jQuery code doesn't run properly.

However , If the above code isn't working,

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 

Try Include Script.

It may be the fact that the download jQuery is broken.

Thank you.

P.s. I am not native so My english may sound a bit confuse