May 2017
Intermediate to advanced
448 pages
10h 10m
English
While the animated .show() and .hide() methods are certainly flashy, in practice, they animate more properties than are useful. Fortunately, jQuery offers a couple of other prebuilt animations for a more subtle effect. For example, to have the whole paragraph appear just by gradually increasing the opacity, we can use fadeIn('slow') instead:
$(() => { $('p') .eq(1) .hide(); $('a.more') .click((e) => { e.preventDefault(); $('p') .eq(1) .fadeIn('slow'); $(e.target) .hide(); });});
Now when we look at the paragraph during the effect, it looks like this:

The difference here is that the .fadeIn() effect starts ...
Read now
Unlock full access