Lesson 11 in JQuery not accepting code


#1

I need help. I believe my code is correct to fade in the button fast and with opacity 1 or 100% ( 'fast', 1); but every time i run code, it states an error. what error do i have or is it a glitch? because i did next lesson and everything went through just fine with all same syntax.

$(document).ready(function() {
$("div").mouseenter(function() {
$("div").fadeTo('fast', 1);
});
});

`


#2

Having the same problem, the error suggests to look if I putted in the value 1, but this is what I did..


#3

See this discussion to find a solution!


#6

It looks like your missing the hide()
$('div').hide().fadeTo('fast', 1);


#7

Make sure <script type='text/javascript' src='script.js'></script> is in your <head> section in the HTML


#8

I am having the same issue and yes the script command is entered in the head section.
Any ideas?


#9

When the preview page pops up after you submit your code, hover the mouse over the div that says "Click Me", and wait 2 seconds. That's where I originally got stuck.


#10

$(document).ready(function() {
    $('div').mouseenter(function() {
        $('div').fadeTo('fast',1);
    });
});

this is my code try it
the only problem with me was that I wrote fadeto() instead of fadeTo()


#11

I fixed it, and it is really stupid.

If you open your browser's developer tools (F12, usually), you'll see the error Uncaught ReferenceError: $ is not defined. Basically, this means that JQuery is actually not loaded.

To fix this, add the line <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> to your index.html file before (because it must be loaded before you use it) your <script type="text/javascript" src="script.js"></script> line. This will load JQuery from Google's CDN.

For more information on adding JQuery to a web page, check out W3School's article on the matter.


#12

Yap, this solve the problem.
THanks


#13