I’m new to jQuery, but not new to programming. Still I cannot find out whats wrong with this simple piece of code:
$(document).ready(function() {
$('.footer').click(function() {
$('.footer').fadeOut('slow');
});
});
It won’t work on my own website, but it does work when I use codeacademy.
What is wrong with this?
Edit: Awhile ago I made this question. It was a simple thing I did not understand back then when I started jQuery. The solution was to import the library first before taking any other actions in javascript. The code did work in codeacedemy because the library is automatically imported. This is very important to know for each beginner, but this piece of infomation is everywhere on the web.
Few checkpoints…
Make sure you include the jQuery library, inside your
<head>.If that’s fine, do you have an element with the class
.footer? If not, is it anID? In that case, you need to add this:Actually, this can be done in another best way: