I'm doing a work in html, css, javascript and ajax and the goal is to change the tab style with the id of the sensor name when it is clicked, but says that the element does not exist and wanted to know what error it I'm committing.
I'm basically importing from an xml file and putting the tabs with the name of the sensor name of the xml file inside a tag named list_sensors
strHtmlNomes = "";
for(i = 0; i < nomesSensores.length; i++)
{
nomeSensor = nomesSensores[i];
strHtmlNomes +='<div><a href="#" id="'+nomeSensor+'" class="tablinks" onclick="openSensor('+nomeSensor+')">'+nomeSensor+'</a></div>';
}
document.getElementById("list_sensores").innerHTML = strHtmlNomes;
and before closing the html I have this javascript script
function openSensor(nomeSensor){
document.getElementById(nomeSensor).style.color = "blue";
}