JavaScript, JQuery, HTML5, node. js instances Daquan-Reading notes 3

Source: Internet
Author: User
Tags closure

There are a lot of techniques, very many examples. Just learn slowly, practice slowly!! Now this book is "javascript combat----javascript,JQu ery,HTML5, N ode.js instance full "

JavaScript, JQuery, HTML5, node. js instances Daquan-Reading notes 2

3.3 Responding to mouse actions

The effect of Figure 3-2 is already there, and you need to manipulate the mouse to show the photos you want to see. This requires adding events to the corresponding place.

3.3.1 Response Small Photo click action

A Eg.showthumb () method showing a list of small graphs is provided in the 3.2.3 code. You want to display a large picture when you click a small picture. This requires calling the Eg.showbig () method, which only responds to the Click event when the small picture is clicked, so it needs to be implemented with the Eg.addlistener () method, and the detailed code is shown in "Example 3-4".

"Example 3-4 response Small Photo click action"

The 9th line in "Example 3-4" is the code that responds to a small photo click action, where a closure is used. That is, a self-invoking anonymous function.

(function () {}) () is the simplest closure.

The contents of the curly braces run sequentially. Assuming you get rid of lines 9th and 14th, you'll find that the last 1 in the current group photo is always displayed. In the body of the For statement, the value of the variable is generally passed to the internal binding event.

most soldiers attack the actual type of JavaScript


JavaScript, JQuery, HTML5, node. js instances Daquan-Reading notes 3

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.