Javascript - efficiently insert multiple HTML elements

后端 未结 2 1343
深忆病人
深忆病人 2021-01-02 17:32

I\'d like to create a select element with a list of a user\'s Facebook friends (obtained as a JSON object). I hardcode

提交评论

  • 2021-01-02 18:16

    Try this in your for loop instead:

    var o = document.createEleent('option');
    o.setAttribute('value', response.data[i].id);
    o.appendChild(document.createTextNode(response.data[i].name));
    msgContainer.appendChild(o);
    
    0 讨论(0)
  • 提交回复
    热议问题