Javascript DOM errors

前端 未结 5 1070
没有蜡笔的小新
没有蜡笔的小新 2021-01-25 13:45

this is my javascript code , I am trying to create a dynamic list in HTML with data I recieve from the server , The data is of type \"json\"

My Javascript snippet

5条回答
  •  醉话见心
    2021-01-25 14:32

    That's an error :

    title.setAttribute=('style','float:right');
    

    do:

    var title = document.createElement('p');
        title.innerHTML = data[i].title;
        title.style.cssFloat = 'right';
    link.appendChild(title);
    

    and

    var pic = document.createElement('img');
        pic.src = data[i].pictureURL;
        pic.width = '80px';
        pic.height = '100px';
        pic.style.paddingLeft = '10px';
    link.appendChild(pic);
    

    etc......

提交回复
热议问题