+ 3

This is my two pictures I want when one pic will be hidden second will show but my setinterval don't working why

$(function(){ setInterval(function(){ $('#one').hide(); $('#one1').show() },1000) })//

22nd May 2017, 7:24 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
12 Antworten
+ 6
var tmp = false; function(){ function Toggle(){ if(tmp){ $("#one").hide(); $("#one1").show(); }else { $("#one1").hide(); $("#one").show(); } tmp = !tmp; } setInterval(Toggle,1000); }
22nd May 2017, 8:25 PM
MR Programmer
MR Programmer - avatar
+ 3
its your mistake not setInterval () this code will always hide the image with one id.
22nd May 2017, 8:12 PM
MR Programmer
MR Programmer - avatar
+ 3
$("one").hide() will always hide image with id one $("one1"). show () will always​ show image with id one1 wait let me code what you want...
22nd May 2017, 8:18 PM
MR Programmer
MR Programmer - avatar
+ 3
function(){ function Toggle(){ $("#one").fadetoggle(); $("#one1"). fadetoggle(); } setInterval(Toggle,1000); }
22nd May 2017, 8:31 PM
MR Programmer
MR Programmer - avatar
+ 3
@rose fade toggle will not give you the result
22nd May 2017, 8:34 PM
MR Programmer
MR Programmer - avatar
+ 1
Yeah but I want to everyseconde be hide and show
22nd May 2017, 8:23 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 1
you can also try to use .fadetoggle() method on just one element instead,if your both elements on same place and with same size.
22nd May 2017, 8:27 PM
Rose Sevenyears
Rose  Sevenyears - avatar
+ 1
how
22nd May 2017, 8:29 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 1
ok guys I will try tomorrow and say u
22nd May 2017, 8:52 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
0
why
22nd May 2017, 8:15 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
- 1
yep,like this :D but I guess we can fadetoggle just higher element :)
22nd May 2017, 8:33 PM
Rose Sevenyears
Rose  Sevenyears - avatar
- 1
Yeah...guess it will be weird since it will increase opacity and then will go back... Just thought how it will work sorry :D
22nd May 2017, 8:37 PM
Rose Sevenyears
Rose  Sevenyears - avatar