Jump to content

A simple for loop not working :S


RobertP

Recommended Posts

Lots of little errors... this'll fix it.  You also have to set left: auto (not 0) for your right div.

var loadedAdvertisements = new Array();

function updateAdvertisements() {
    if (loadedAdvertisements["left"] == null) {
        loadedAdvertisements["left"] = $("<div id=\"leftAdvertisement\"></div>");
        $("body").append(loadedAdvertisements["left"]);
        //i do not want to use the line below
        //loadedAdvertisements["left"].show(1000);
    }
    if (loadedAdvertisements["right"] == null) {
        loadedAdvertisements["right"] = $("<div id=\"rightAdvertisement\"></div>");
        $("body").append(loadedAdvertisements["right"]);
        //loadedAdvertisements["right"].show(1000);
    }
    //i want to the for for loop below
    for (var i in loadedAdvertisements)
        loadedAdvertisements[i].show(1000);
}

$(window).ready(function() {
    updateAdvertisements();
});​

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.