there is such a code

var ctx = document.getElementById("line-chart1").getContext("2d"); window.weightChart1 = new Chart(ctx, { type: 'line', data: lineChartData, options: lineChartOptions, }); document.getElementById("line-chart-legend").innerHTML = weightChart1.generateLegend(); 

he catches the first one and stops there, and I need him to fill in all the found ideas.

  • 2
    id are unique, so there is only one element. - Grundy
  • id diva, and my table is secret_coder
  • five
    so what's your table? The id is still unique on the page. and there will be only one element - Grundy
  • here, read webref.ru/html/attr/id , it will be useful ... - Air

1 answer 1

 var ctx = document.getElementById("line-chart1").getContext("2d"); window.weightChart1 = new Chart(ctx, { type: 'line', data: lineChartData, options: lineChartOptions, }); var aElem=document.querySelectorAll("#line-chart-legend"); for(i=0;i<aElem.length;i++){ aElem[i].innerHTML = weightChart1.generateLegend(); }