我调用我的 api 并返回 json 对象,然后它会生成很多充满内容的 div。但我一直使用连接来插入我的对象属性。有更好的方法吗?
$.each(JSON, function(key, value) { 
  var content = display_mention(value);
  $("#mentions_container").append(content);
    });
    function display_mention(mention) {
       //this str will be much more complex and use lots of concatenation
   var str = "<div data-id='" + mention.id +"'> " + mention.texto + "</div></br>";
   return str;
    }