HTML5 practice-set images to grayscale _ html5 tutorial skills-

Source: Internet
Author: User
Previously, to display grayscale images on the web, you only need to manually use the image software for conversion. But now we can implement this process with the help of html5 canvas, without the need to use image editing software. Previously, to display grayscale images on the web, we only need to manually use the image software for conversion. But now we can implement this process with the help of html5 canvas, without the need for image editing software. I used html5 and jquery to make a demo to demonstrate how to implement this function.

Purpose
This demo will show you how to use html5 and jquery to switch between the grayscale image and the source image when moving the mouse over the image. Before html5 appears, you need to prepare two images, one grayscale image and one original image, to implement this function. But now html5 can be used to achieve faster and easier, because grayscale images are generated directly on the source image. I hope this js Code will help you create a file or image display function.



Jquery code
The following jquery code looks for the target image and generates a grayscale version. When you move the mouse over an image, the grayscale image becomes the primary color.

The Code is as follows:


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.