Creating a unordered list drop down to match my array - how?

This is a gallery I have created (with some help) for my website. I would like to incorporate an unordered list (in a drop down style) between the Next and Back buttons however, I am not sure how to append such code to the jQuery. Any help would be greatly appreciated; thanks!

<a href="#" id="back"> Back </a> - <a href="#" id="next"> Next </a></h2></center>
    <center> <img src='gallery/img01.jpg' id='gallery'>
<center><h4><a href="#" id="back"> Back </a> - <a href="#" id="next"> Next </a>

<script> 
    var image = [];
    var num = 0;

    function fillImgList()
    {
        for(var i = 1; i <= 34; ++i)
        {
            image.push("gallery\\img" + (i < 10 ? "0" : "") + i + ".jpg");
        }
    }
    fillImgList();
    $(function()
    {
        $("#next").click(function() { galleryNext(); });
        $("#back").click(function() { galleryPrevious(); });
    });
    function galleryNext()
    {
        num++;
        $("#gallery").attr('src', image[num % image.length]);
    }
    function galleryPrevious()
    {
        num--;
        if(num < 0)
        {
            num = image.length-1
        }
        $("#gallery").attr('src', image[num % image.length]);
    }
</script>

Answers


One thing you could do is use the insertAfter() or after() functions. You can see in this example: http://jsfiddle.net/83CSK/

You generate the list as a string in javascript then you pass it through as a selector to jquery which will create the dom element and place it after the selector.

Docs on this function can be found here: http://api.jquery.com/insertafter/


Need Your Help

why the sql commands Interval is used for?

php mysql codeigniter

I wrote the following code in model with sql commands interval etc.

Highlight active div after scroll

javascript jquery html css

Is there an easy way to highlight a top with id (apply css-class with specific color f.e.) after user scrolls to it? I have a scrollspy on page, but it seems that plugin will not help me, so I can't