jeudi 13 août 2015

img insert into HTML from javascript

So I am trying to insert images into <marquee> from a js file. This is what my js file looks like?

      function buildList(){
            var data= ['logo1.png', 'logo2.png', 'logo3.png'];

            //var data2 = [{2:"hello"},{3:"world"},{6:"PSI"},{4:"ali"},{7:"buck"},{1:"hello"},{8:"albert"},{5:"wow"}];
            var marquee = document.getElementsByTagName('marquee');


            for(var i in data){

                    var img = new Image();
                     img.onload = function() {

                    //var newListItem = ' ' + data[i] +  ' there should be an img coming in from an array here';


                                   return img;
                };
                    img.src = data[i];
                    marquee[0].innerHTML  +=  img ;
            //http:http://ift.tt/1cWxZTP"alt="Milford Sound in New Zealand' "Width=80 Height=80" ' + img;
            }   







        }

However when I look at the developer console in chrome, I get no error messeges by inside the marquee it is giving me [object HTML ImageElement]... What am i doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire