jquery - Three different onclick events should show three different sets of slides of the same slider -



jquery - Three different onclick events should show three different sets of slides of the same slider -

i have slider becomes visible when user clicks on image map. have 3 different image maps on page , each should show different grouping of slides when activated. slider shows same slides each of image maps. how can accomplish without having create 3 different sliders. hoping utilize 1 slider picks out right slides when 1 of image maps clicked on. enclosed html , js file.

$(document).ready(function () { $('#slider_option').click(function(){ $('#slider').css('visibility','hidden'); $('#slider_option').css('visibility','hidden'); $('#gallery1').fadeto( 1200, 1,function(){ }); }); var slidecount = $('#slider ul li').length; var slidewidth = $('#slider ul li').width(); var slideheight = $('#slider ul li').height(); var sliderulwidth = slidecount * slidewidth; $('#slider').css({ width: slidewidth, height: slideheight }); $('#slider ul').css({ width: sliderulwidth, marginleft: - slidewidth }); $('#slider ul li:last-child').prependto('#slider ul'); function moveleft() { $('#slider ul').animate({ left: + slidewidth }, 200, function () { $('#slider ul li:last-child').prependto('#slider ul'); $('#slider ul').css('left', ''); }); }; function moveright() { $('#slider ul').animate({ left: - slidewidth }, 200, function () { $('#slider ul li:first-child').appendto('#slider ul'); $('#slider ul').css('left', ''); }); }; $('a.control_prev').click(function () { moveleft(); }); $('a.control_next').click(function () { moveright(); }); $('map').click(function(){ $('#gallery1').fadeto( 1200, 0 ); $('#slider').css('visibility','visible'); $('#slider_option').css('visibility','visible'); }); }); , here html: <!doctype html> <html> <head> <meta charset="utf-8" /> <title>paulienlombard.com</title> <link rel="stylesheet" type="text/css" href="index.css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript" src="index.js"></script> </head> <body> <div id="container"> <div id="content" class="clearfix"> <div style="fgimg"> <img src="homepage_im.png" class="fgimg" alt="homepage" width="960" height="600" usemap="#gallery" id="gallery1"/> <map name="gallery" id="gallery"> <area shape="rect" coords="25,225,200,450" style="outline:none" href="#" alt="" /> <area shape="rect" coords="750,225,925,450" style="outline:none" href="#" alt="" /> <area shape="rect" coords="375,275,575,425" style="outline:none" href="#" alt="" /> </map> </div> </div> <div id="header"> <img src="logo_im.png" alt="logo paulien lombard" id="logo"> </div> <div id="slider" class="gallery"> <a href="#" class="control_next">&gt;</a> <a href="#" class="control_prev">&lt;</a> <ul> <li><img src="dog.png" class="slide" alt="dog" id="im6"></li> <li><img src="disk.png" class="slide" alt="disk" id="im7"></li> <li><img src="fruit.png" class="slide" alt="fruit" id="im8"></li> <li><img src="garden.png" class="slide" alt="garden" id="im9"></li> <li><img src="girl.png" class="slide" alt="girl" id="im10"></li> <li><img src="vondel.png" class="slide" alt="vondel" id="im1"></li> <li><img src="rome2.png" class="slide" alt="rome2" id="im2"></li> <li><img src="room.png" class="slide" alt="room" id="im3"></li> <li><img src="rome.png" class="slide" alt="rome" id="im4"></li> <li><img src="berkeley.png" class="slide" alt="berkeley" id="im5"></li> </ul> </div> <div id="slider_option"> &#10005; </div> </div> </body> </html>

here find jsfiddle shows possible solution. rather talk slides , other items, allow think images on screen. saying here want show subset of possible images , not of them based upon events. in sample, have 6 images loaded screen broken 3 sets (groupings). depending on button clicked, corresponding set made visible.

this 1 possible solution. other solutions dynamically load images when appropriate set selected more efficient gives indication of general notion.

the code code solution is:

$(function() { function hideall() { $(".group img").hide(); } $("#set1").click(function() { hideall(); $(".group .set1").show(); }); $("#set2").click(function() { hideall(); $(".group .set2").show(); }); $("#set3").click(function() { hideall(); $(".group .set3").show(); }); });

which sets callbacks each of 3 buttons uses class selectors determine groups hide , show.

jquery html

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -