Thursday, 15 August 2013

javascript - html button for fadeIn and FadeOut -



javascript - html button for fadeIn and FadeOut -

hey guys i'm making own website fun , next code makes list of shapes appear. know how incorporate button instead of fadeout code create when click button, "hide menu" button. shapes fadeout. because code have @ moment means shapes fade out on time. pls help!

<script> $(document).ready(function(){ $("button").click(function(){ $("#div1aside").fadein(100); $("#div2aside").fadein(200); $("#div3aside").fadein(300); $("#div4aside").fadein(400); $("#div5aside").fadein(500); $("#div6aside").fadein(600); $("#div7aside").fadein(700); $("#div8aside").fadein(800); $("#div9aside").fadein(900); $("#div10aside").fadein(1000); $("#div11aside").fadein(1100); $("#div12aside").fadein(1200); $("#div13aside").fadein(1300); $("#div14aside").fadein(1400); $("#div15aside").fadein(1500); $("#div16aside").fadein(1600); $("#div17aside").fadein(1700); $("#div18aside").fadein(1800); $("#div1aside").fadeout(17670); $("#div2aside").fadeout(17660); $("#div3aside").fadeout(17650); $("#div4aside").fadeout(17640); $("#div5aside").fadeout(17630); $("#div6aside").fadeout(17620); $("#div7aside").fadeout(17610); $("#div8aside").fadeout(17600); $("#div9aside").fadeout(17590); $("#div10aside").fadeout(17580); $("#div11aside").fadeout(17570); $("#div12aside").fadeout(17560); $("#div13aside").fadeout(17550); $("#div14aside").fadeout(17540); $("#div15aside").fadeout(17530); $("#div16aside").fadeout(17520); $("#div17aside").fadeout(17510); $("#div18aside").fadeout(17500); $("section").fadeout(0); }); }); </script>

if understood question right, should toggle, find simpliest way that:

$(document).ready(function(){ var toggle = 0; $("button").click(function(){ if (toggle === 0) { $("#yourdivstofadein").fadein(yourtimetofadein); toggle = 1; } else if (toggle === 1) { $("#yourdivstofadeout").fadeout(yourtimetofadeout); toggle = 0; } }); });

edit: use:

$(document).ready(function() { $("button").click(function() { $("#yourdivsids").fadetoggle(yourtimetotogglethefade); }); });

but find first way better, because if larn more javascript/jquery, there arent .toggle methods toggle something. improve should larn - , used - first method. -but thats point of view.

javascript jquery html button

No comments:

Post a Comment