Need Help in javascript

Report
Question

Please briefly explain why you feel this question should be reported .

Report
Cancel

I made a image gallery that shows images randomly

Now I was only able to create a button for next but I need a button also for the previous image

a file has been attached with the html file and images

 

 


Attachment

Attachment
in progress 0
JavaScript 4 months 2 Answer 2462 views 0

About rafi1997

Answers ( 2 )

  1. ritwik

    Please briefly explain why you feel this answer should be reported .

    Report
    Cancel

    The solution lies in looping through an array in forward and reverse order. Following example may be useful for you –

    var myStringArray = ["w3","resource"];
    var arrayLength = myStringArray.length;
    for (var i = 0; i < arrayLength; i++) {
        console.log(myStringArray[i]);
    }
    
    var myStringArray = ["w3","resource"];
    var arrayLength = myStringArray.length;
    for (var i = arrayLength - 1; i >= 0; i--) {
        console.log(myStringArray[i]);
    }
    
  2. Please briefly explain why you feel this answer should be reported .

    Report
    Cancel

    When you click on next get the current image id and assign it to another variable. So after you move on to the next image you can get the previous image id from that variable.

    Cheers !!

Leave an answer

Browse

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>