I am working with various JavaScript variables that involve displaying values inside div elements.
goalDiv = "<div class=goal-parent id=goal-parent"+Id+">"+
"<div class=goal>"+
"<div class=top-layer>"+
"<div class=component>"+
"<select class=component-select>"+
"<option id=one><span id='source_name'></span></option>"+
"</select>"+
"</div>"+
"</div>"+
"</div>"+
"</div>";
Id = "some unique div value";
After inserting this goalDiv into a div, I attempt to update the content within it as shown below:
document.getElementById(Id).innerHTML = goalDiv;
document.getElementById('source_name').innerHTML = "changed value";
While the first innerHTML method is successful, the second one fails. Can anyone point out what mistake I might be making?