我使用这部分代码来创建按钮列表
obj.zones[0].forEach(function(entry) {
listDesZones+='<button onclick=enableModification("'+ entry.nomZone +'","'+ entry._id.$oid +'")>' + entry.nomZone + '</button><br>';
});
但是当entry.nomZone包含空格时我遇到了问题 你可以在 Firebug 中看到
大家对此有何看法?
最佳答案
您可以替换空格:
entry.nomZone.replace(/\s/g,'');
关于javascript 名称中带空格和不带空格的空格区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34674249/