A cool template trick for Movable Type users

I saw an effect in a WordPress theme that was pretty novel, so I thought I would share here how to reproduce it on a Movable Type theme using JQuery.

<script type="text/javascript">
function fadeHeader()
{
     $("#header").hide().fadeIn(5000, undefined);
}
</script>

The code is straight forward (provided you understand JQuery at least somewhat). It grabs the <em>header</em> &lt;div&gt;, hides it and then fades it in over five seconds. If you want to do this automatically, rather than having to call a JavaScript function, just do:

<script type="text/javascript">
$(window).load({
     $("#header").hide().fadeIn(5000, undefined);
});
</script>

Quick note: <em>undefined</em> is passed there because I didn't want to use a callback function. If you have a function that you want to execute as a callback when fadeIn completes, just pass it as a parameter.

Try it.

Leave a comment

March 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Recent Entries

Google's lossy compiler
Google's closure compiler service gets a little too frisky under ADVANCED_OPTIMIZATIONS. Original code: With advanced optimizations enabled, it was able…
The three purposes of the federal income tax law
Businesses will spend about 3.4 billion man-hours and individuals about 1.7 billion hours figuring out their taxes this year.…
Progress of a different sort
You know we have reached a level of decadence seldom seen in the history of the West when our women…

Subscribe

Advertisements

OpenID accepted here Learn more about OpenID