RobertP Posted June 4, 2012 Share Posted June 4, 2012 http://jsfiddle.net/JcLvr/2/ my issue is displaying the div's after creating them (to display all at once). i wish to have the divs in an array so i can remove them anytime aswell. Link to comment https://forums.phpfreaks.com/topic/263609-a-simple-for-loop-not-working-s/ Share on other sites More sharing options...
smoseley Posted June 4, 2012 Share Posted June 4, 2012 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(); }); Link to comment https://forums.phpfreaks.com/topic/263609-a-simple-for-loop-not-working-s/#findComment-1350999 Share on other sites More sharing options...
smoseley Posted June 4, 2012 Share Posted June 4, 2012 FYI, here's your update: http://jsfiddle.net/JcLvr/4/ Link to comment https://forums.phpfreaks.com/topic/263609-a-simple-for-loop-not-working-s/#findComment-1351000 Share on other sites More sharing options...
RobertP Posted June 5, 2012 Author Share Posted June 5, 2012 FYI, here's your update: http://jsfiddle.net/JcLvr/4/ simply amazing, thank you very much! Link to comment https://forums.phpfreaks.com/topic/263609-a-simple-for-loop-not-working-s/#findComment-1351255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.