javascript - Jquery slide hide-show div with an image -


i have banner need changing on click. @ moment have hidden 2nd banner , banner 1 shows. when click arrow want banner 1 hide , banner 2 show etc.. problem tried using html.

<div class="homearrow"><img src="https://cdn1.iconfinder.com/data/icons/defaulticon/icons/png/256x256/arrow-right.png" alt=""/></div> 

i want homearrow click button show next banner

but not sure how connect jquery...

this js fiddle:

http://jsfiddle.net/8a7gl/152/

hide / show 1 banner @ time:

$(".homearrow").on('click',function () {     $(".homeimage").slidetoggle(); }); 

http://jsfiddle.net/8a7gl/152/

sliding left right can achieved little more code in jquery see: http://www.learningjquery.com/2009/02/slide-elements-in-different-directions/

you use addclass/removeclass , make sliding css3 transitions. improve quality.

update:

here left / right slidy. html:

<div class="homebannercontainer" style="display: block">     <div id="a1" class="homeimage">          <h4>banner 1</h4>          <img src="http://www.nostomachforcancer.org/wp-content/uploads/2013/08/nsfc_scam_banner_50percent.jpg" alt="" />         <div class="homebanner">              <h3>my banner</h3>          </div>     </div>     <div id="a2" class="homeimage" style="display: none">          <h4>banner 2</h4>          <img src="http://www.nostomachforcancer.org/wp-content/uploads/2013/08/nsfc_scam_banner_50percent.jpg" alt="" />         <div class="homebanner" style="display: none">              <h3>my banner 2</h3>          </div>     </div>     <div class="homearrow">         <img src="https://cdn1.iconfinder.com/data/icons/defaulticon/icons/png/256x256/arrow-right.png" alt="" />     </div> 

css:

    $(".homearrow").on('click', function () {     $('.homeimage').animate({         width: 'toggle'     });  }); 

demo: http://jsfiddle.net/8a7gl/174/


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -