The article from NETTUTS has a very good effect, which is a bit similar to the Flash effect. Here, I will not mention the implementation steps in the original article, the implementation logic is relatively simple, that is, the slideDown () method,
Jquery slideDown () method to achieve the sliding effect.
Copy codeThe Code is as follows:
// Shows a given element and hides all others
Function showViaKeypress (element_id)
{
$ (". Container" ).css ("display", "none ");
$ (Element_id). slideDown ("slow ");
}
// Shows proper DIV depending on link 'href'
Function showViaLink (array)
{
Array. each (function (I)
{
$ (This). click (function ()
{
Var target = $ (this). attr ("href ");
$ (". Container" ).css ("display", "none ");
$ (Target). slideDown ("slow ");
});
});
}
The keypress () method is used to listen to keyboard keys, which is actually not difficult, but we seldom use button listening on pages. This example is novel and worth your reference, it can be used in projects if necessary.
Copy codeThe Code is as follows:
$ (Document). keypress (function (e)
{
Switch (e. which)
{
// User presses the ""
Case 97: showViaKeypress ("# home ");
Break;
// User presses the "s" key
Case 115: showViaKeypress ("# about ");
Break;
// User presses the "d" key
Case 100: showViaKeypress ("# contact ");
Break;
// User presses the "f" key
Case 102: showViaKeypress ("# awards ");
Break;
// User presses the "g" key
Case 103: showViaKeypress ("# links ");
}
});