Jquery implements how to display a large image when the mouse slides over a small image. jquery slides over

Source: Internet
Author: User

Jquery implements how to display a large image when the mouse slides over a small image. jquery slides over

This example describes how to display a large image when jquery moves the mouse over a small image. Share it with you for your reference. The specific implementation method is as follows:

Copy codeThe Code is as follows: <Head>
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>
<Title> </title>
</Head>
<Style type = "text/css">
Li {list-style: none; float: left; margin-left: 10px ;}
</Style>
<Script type = "text/javascript" src = "jquery-1.8.2.min.js"> </script>
<Script type = "text/javascript">
Var data = {
"Images/11_s.jpg": ["images/11_ B .jpg", "Beauty 1"],
"Images/22_s.jpg": ["images/22_ B .jpg", "Beauty 2"],
"Images/33_s.jpg": ["images/33_ B .jpg", "Beauty 3"],
"Images/44_s.jpg": ["images/44_ B .jpg", "Beauty 4"]
};
$ (Function (){
$. Each (data, function (key, value ){
// Initialize the last div to hide
$ ("Div"). last (). hide ();
// Create a node for the thumbnail
Var smallPath = $ ("// Set the big image address and name
BigImgPath = smallPath. attr ("bigMapPath", value [0]);
BigImgName = smallPath. attr ("bigMapName", value [1]);

$ ("Div"). first (). append (smallPath );

// Add an event to the widget
SmallPath. mouseover (function (){
// Fade-in effect of the last div
$ ("Div"). last (). fadeIn ("fast ");
// Obtain the big image address
$ ("# Show"). attr ("src", $ (this). attr ("bigMapPath "));
// Obtain the big image name and set the style
$ ("# ImgTitle "). text ($ (this ). attr ("bigMapName" )).css ({"background": "# ebf1de", "padding": "10px", "margin-bottom": "10px "});
});
SmallPath. mouseout (function (){
$ ("Div"). last (). fadeOut ("fast ");
});
});
});
</Script>
<Body>
<Div> </div>
<Div>

</Div>
</Body>
</Html>

I hope this article will help you with jQuery programming.

Related Article

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.