JavaScript mouse hover picture shows the original image moved out of the mouse after the original image disappears (more pictures) _ Graphic effects

Source: Internet
Author: User
Tags visibility
The specific usage is this:
Putting JavaScript code in front of </body> (putting script code at the bottom of the page helps improve page speed, but I don't have a personal experience right now)
Copy Code code as follows:

<script language=javascript>
function mouseoutpic ()///When the mouse is moved out, hide the original artwork
{
if (window.event.toelement.id!= "img000") bigPic.style.visibility = "hidden";
If the mouse is not on the img000, hide the area
}
function Mouseoverpic (IMGSRC)///When the mouse is over a small image, display the original artwork
{
var seebig = document.getElementById ("Bigpic"); Get the div element that will display the original area
var newimg = document.createelement ("img"); Create an IMG element to assign the original src to this element
newimg = " "; Notice here, it's for the entire element, and I've spent a lot of time on this little problem.
alert (IMGSRC);
seebig.innerhtml = newimg; Assign the artwork to the area you want to display
}
</script>

Here is the HTML code:
Copy Code code as follows:

<!--The following ID is the img000 element is a thumbnail, the mouse hovers over it appears the original-->
The Mouseoverpic function is called in the <!--onmouseover method (see above), and the parameters passed to it are the original url-->
<!--call Mouseoverpic, set the original display area to visible-->

<!--when the page is initialized, the original display area is hidden-->
<div id= "Bigpic" style= "Visibility:hidden;" >
</div>

The above code does not control where the original image appears, and if it involves a position near the edge of the window, it will use attributes such as offsetleft.
Think about it, actually this is quite simple. The need to write JavaScript more attention to detail, this is too important, inadvertently will be wrong, the worst is not know where the wrong.
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.