Sunday, 15 February 2015

javascript - simplifying a long list of click functions -


I am using an image slider on my site: it works well for me.

When the visitor clicks on a thumbnail below the slider, it jumps on a particular image. This is done by one click function for each thumbnail only starting with some thumbnails. There is a long list of clicked tasks ending with

It seems that there should be a loop in the proper manner. When the visitor clicks any thumbnail, the click is clicked on the loop to start, which is clicked and calls the cycle with the clicked number.

Change all your images to use a square instead of ID:

< Pre> & lt; Input type = "image" class = "goTo" src = "../images / cokehouse / housing / thumbnail / tn_chfood_29.png" width = "80" height = "60" & gt;

Then, do this:

  $ ('. GoTo'). Click (function (event) {event.preventDefault (); // If you do not need this line for your code, see the comment below for clarification. Var cur = $ ('. GoTo'). Index ($ (this )); $ ('# Acc_sl'). Cycle (cr);});  

No comments:

Post a Comment