I am still a newbie at Javascript. I tried writing a program to make images fadeToggle all the time, so I used the while conditional statement (combined with a constant variable); after running that and freezing my computer (then remembering that viruses are basically infinite operations) I searched on here a bit, realized I should probably, indeed, never use infinite loops.
(Actually I want shimmer -- meaning to go from opacity 0.9 to 0.6 to 0.9 etc...) so its not the same as fadeToggle, but the same question remains; how do I make it go infinitely?(without writing malicious code.)
This is what I wrote, for your reference:
<script>
$(document).ready(function(){
var always10 = 10;
while (always10 == 10) {
$('.pimg').fadeToggle(2600);
}
});
</script>
Also, I've found out on another thread that while(true)
is better for infinite loops. So another question: are infinite loops sometimes OK?