Looping through image with the lenght property and its not looping











up vote
-3
down vote

favorite












It stops at the last image but I want it to run infinitely, but it won't loop it stops at the end of the last .img item



function slider(){
var sc = $(".sect .img").length;
var count = 1;

setInterval(function(){
$(".sect #"+ count).delay(3500);
$(".sect #"+ count).fadeIn(3500);
$(".sect #"+ count).delay(5500);
$(".sect #"+ count).fadeOut(3500);

if(count !== sc){
count = count + 1;
}else{
count = 1;
}
} 12500);
};









share|improve this question




















  • 1




    see meta.stackoverflow.com/questions/285551/…
    – Moshe Slavin
    Nov 7 at 15:09










  • do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
    – Calvin Nunes
    Nov 7 at 16:41

















up vote
-3
down vote

favorite












It stops at the last image but I want it to run infinitely, but it won't loop it stops at the end of the last .img item



function slider(){
var sc = $(".sect .img").length;
var count = 1;

setInterval(function(){
$(".sect #"+ count).delay(3500);
$(".sect #"+ count).fadeIn(3500);
$(".sect #"+ count).delay(5500);
$(".sect #"+ count).fadeOut(3500);

if(count !== sc){
count = count + 1;
}else{
count = 1;
}
} 12500);
};









share|improve this question




















  • 1




    see meta.stackoverflow.com/questions/285551/…
    – Moshe Slavin
    Nov 7 at 15:09










  • do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
    – Calvin Nunes
    Nov 7 at 16:41















up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











It stops at the last image but I want it to run infinitely, but it won't loop it stops at the end of the last .img item



function slider(){
var sc = $(".sect .img").length;
var count = 1;

setInterval(function(){
$(".sect #"+ count).delay(3500);
$(".sect #"+ count).fadeIn(3500);
$(".sect #"+ count).delay(5500);
$(".sect #"+ count).fadeOut(3500);

if(count !== sc){
count = count + 1;
}else{
count = 1;
}
} 12500);
};









share|improve this question















It stops at the last image but I want it to run infinitely, but it won't loop it stops at the end of the last .img item



function slider(){
var sc = $(".sect .img").length;
var count = 1;

setInterval(function(){
$(".sect #"+ count).delay(3500);
$(".sect #"+ count).fadeIn(3500);
$(".sect #"+ count).delay(5500);
$(".sect #"+ count).fadeOut(3500);

if(count !== sc){
count = count + 1;
}else{
count = 1;
}
} 12500);
};






jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 18:21

























asked Nov 7 at 15:01









onyima ogochukwu

12




12








  • 1




    see meta.stackoverflow.com/questions/285551/…
    – Moshe Slavin
    Nov 7 at 15:09










  • do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
    – Calvin Nunes
    Nov 7 at 16:41
















  • 1




    see meta.stackoverflow.com/questions/285551/…
    – Moshe Slavin
    Nov 7 at 15:09










  • do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
    – Calvin Nunes
    Nov 7 at 16:41










1




1




see meta.stackoverflow.com/questions/285551/…
– Moshe Slavin
Nov 7 at 15:09




see meta.stackoverflow.com/questions/285551/…
– Moshe Slavin
Nov 7 at 15:09












do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
– Calvin Nunes
Nov 7 at 16:41






do not post code as image, it's terrible to see and terrible to debug. Edit your question and add or a code block by pressing CTRL+K or a snippet (CTRL+M) with your current code.
– Calvin Nunes
Nov 7 at 16:41



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192088%2flooping-through-image-with-the-lenght-property-and-its-not-looping%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192088%2flooping-through-image-with-the-lenght-property-and-its-not-looping%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings