The mouse hovers over the small picture, automatically appears the big picture The code

Source: Internet
Author: User
First the original picture is a big picture,
<div id= "_images" style= border: #000 1px solid;overfow:hidden;width:100px;height:100px "></div>
1. The small figure is located in the Div, with style=overfow:hidden;width:100px;height:100px;
 To limit the display size of the picture, only shown as high width 100px
<div id= "Enlarge_images" style= "Position:absolute; Z-index:2; Display:none; " ></div>
2. Used to show the div,style=display:none of the large picture, which is the original size; let it not show first
<SCRIPT>
Function Show (_this) {
document.getElementById ("Enlarge_images"). InnerHTML = "<div></div>";
Move_layer (event);  Where to appear when displayed
}
Hover the mouse over the small picture, display with enlarge_images layer
function Hide (_this) {
document.getElementById ("Enlarge_images"). InnerHTML = "";    document.getElementById ("Enlarge_images"). style.display= "None";
}
Mouse left, enlarge_images layer does not show
function Move_layer (_event) {
document.getElementById ("Enlarge_images"). Style.left=_event.x;
document.getElementById ("Enlarge_images"). Style.top=_event.y;
}
</SCRIPT>
If it's two pictures, change it here.
Function Show (_this) {
document.getElementById ("Enlarge_images"). style.display= "";
document.getElementById ("Enlarge_images"). InnerHTML = "<div></div>";   _this.src  to a large picture of SRC
Move_layer (event);  Where to appear when displayed
}
For example, the small map src is 15.jpg, the large map address should be set to regular, such as 15_large.jpg, change the function
Function Show (_this) {
var _src = _this.src.replace (/\./ig, "_large.");
document.getElementById ("Enlarge_images"). style.display= "";
document.getElementById ("Enlarge_images"). InnerHTML = "<div></div>";
Move_layer (event);
}
}
document.getElementById ("Enlarge_images"). style.display= "";
The regular expression here is simple, putting the "." In the 15.jpg. Replace with "_large." You get 15_large.jpg.

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.