From the documentation, I found this example:
We can animate any element, for example a simple image:
<div id="clickme">
Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123" />
With the element initially shown, we can hide it slowly:
$('#clickme').click(function() {
$('#book').fadeOut('slow', function() {
});
});
I remember, 5 years ago, that NEVER ever refer to any element until it is defined. Does this rule still apply? So would I have to put all this code in the footer of my webpage? Or can I put it in a separate file and import it into the footer? What is the best practice?
source
share