jquery switching function (hover,toggle)

Source: Internet
Author: User

1.hover: (Mouse hover and leave event)

A method that mimics the hover event (moving the mouse over an object and moving out of the object). This is a custom method that provides a "keep in" state for frequently used tasks. The first function that is specified is triggered when the mouse moves over a matching element. When the mouse moves out of this element, the specified second function is triggered. Also, it is accompanied by detection of whether the mouse is still in a particular element (for example, an image in a div), and, if so, continues to remain in a "hover" state without triggering a move-out event (fixed a common error using the Mouseout event).

ParametersOver,outFunction,functionV1.0

Over: The mouse moves to the function to be triggered on the element

Out: The mouse moves out of the element to trigger the function

outObjectV1.4

Event functions that trigger execution when the mouse moves over an element or moves out of an element

For example:( the mouse hover up the font to red and leave to black )

//         hover and leave the event, the first one is to move up, the second is to leave        $ ("#ho"). Hover (function  () {            $ (this). CSS ("Color", "red");         function () {            $ (this). CSS ("Color", "black");        }); 

<p id= "Ho1" >    wwww    www    <br/>    www    www</p>

2.toggle: Hide and show:

Used to bind two or more event handler functions in response to a rotating click event of the selected element. If the element is visible, toggle to hidden, or toggle to visible if the element is hidden.
ParametersFn,fn2,[fn3,fn4,...]Function,....V1.0

fn: The function to execute the first few clicks.

FN2: The function to be executed when the second number of hits is clicked.

FN3,FN4,...: The function to be executed more than once when clicked.

[Speed] [, FN]String,functionV1.0

Speed: Hides/shows how fast the effect is. The default is "0" milliseconds. Possible values: Slow,normal,fast. "

fn: The function that executes when the animation is complete, once for each element.

[Speed], [easing], [FN]String,string,functionV1.4.3

Speed: Hides/shows how fast the effect is. The default is "0" milliseconds. Possible values: Slow,normal,fast. "

Easing: (Optional) is used to specify the toggle effect, the default is "Swing", the available parameters "linear"

fn: The function that executes when the animation is complete, once for each element.

SwitchBooleanV1.3

Used to determine the display/hide switch. True-display element, false-hide element

Example: ( hide/Show dynamic Toggle when a button is clicked )

        $ ("#ho1"). Click (function() {            $ ("#ho"). Toggle (function  () {                alert ("vanishing") )            },function  () {                alert ("appears")            })         ;

jquery switching function (hover,toggle)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.