Confused with jQuery show/hide for images -


i have 7 images lined on 1 of pages. have show/hide functionality working shows odd images "odd" button , shows images "even" button. way works if click on odd button, shows odd. , vise versa ones.

however, if odd images shown , click on button, want them shown, adds them shown. if nothing shown, clicking on button should show images? same thing odd images.

but if images shown, clicking should show images , hide odd ... clicking odd should show odd , hide even.

i hope makes sense. not sure how work. need conditional statement? don't know check for.

here working code, not how want work.

<script> $(function () {     $("#evenbutton").click(function () {         $("img").show("slow");         $("img:even").show("slow");     }); }) </script>  <script> $(function () {     $("#oddbutton").click(function () {         $("img").show("slow");         $("img:even").hide("slow");         $("img:odd").show("slow");     }); }) </script> 

i'm finding hard understand question want images toggle between hidden , shown when button pressed?

i've updated based on read through of question

$("#evenbutton").click(function () {     if($("img:even").is(':visible') && $("img:odd").is(':visible')) {         $("img:odd").toggle("slow");             } else {         $("img:even").show("slow");     } });  $("#oddbutton").click(function () {     if($("img:odd").is(':visible') && $("img:even").is(':visible')) {         $("img:even").toggle("slow");             } else {         $("img:odd").show("slow");     } }); 

http://jsfiddle.net/hxycx/2/


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -