0

I am testing an app on IE.

I'm having the problem reading the ` character when the (dynamic) table is read.

list.forEach(item=>{
  let child = document.createElement("tr");
  child.innerHTML = `<td>${item.id}</td><td>${item.name}</td><td>${item.password}</td><td>${item.email}</td><td>${item.sex}</td><td>${item.country}</td><td>-</td><td>-</td>`;
  table.appendChild(child);
})

If it can be fixed, how can I do this?

a_l_e_x
  • 408
  • 1
  • 6
  • 20
  • 1
    I believe that's ES6 syntax, and IE only supports up to ES5. The solution would be to rewrite the string using ' or " quotes. – Tim Feb 08 '22 at 11:58
  • @Tim so instead of ` I should put ' or " ? – a_l_e_x Feb 08 '22 at 11:59
  • 1
    IE11 does not support ES6 syntax and by extension, template literals. You need to use concatenation to construct your string, and it's not just replacing backpacks with `"`, since `${item.name}` will be printed as-is in a normal string. – Terry Feb 08 '22 at 12:05

1 Answers1

2

IE supports ES5.

You will have to rewrite your code.

list.forEach(item=>{
  let child = document.createElement("tr");
  child.innerHTML = '<td>'+item.id+'</td><td>'+item.name+'</td><td>'+item.password+'</td><td>'+item.email+'</td><td>'+item.sex+'</td><td>'+item.country+'</td><td>-</td><td>-</td>';
  table.appendChild(child);
})
Tim
  • 5,435
  • 7
  • 42
  • 62
Ajay Gupta
  • 703
  • 5
  • 11