Das ist allerdings etwas verzwickt und unerwartet. Probiere einmal dies:
for (a = 1; a <= 10; a++) {
document.getElementById('aa').innerHTML += '<input type="text" id="jj' + a + '" value="' + a + '">';
document.getElementById('jj' + a + '').value = 'JJ';
console.log(document.getElementById('jj' + a + '').getAttribute('value'), document.getElementById('jj' + a + '').value);
}
Du siehst, dass die Zuweisung an "value" das Attribut "value" nicht ändert. Jedes Mal wenn Du das innerHTML änderst, wird es neu geparst und das Attribut wird wieder angezeigt.
Die Lösung besteht darin, das Attribut zu setzen:
for (a = 1; a <= 10; a++) {
document.getElementById('aa').innerHTML += '<input type="text" id="jj' + a + '" value="' + a + '">';
document.getElementById('jj' + a + '').setAttribute("value", 'JJ');
console.log(document.getElementById('jj' + a + '').getAttribute('value'), document.getElementById('jj' + a + '').value);
}
Macht man es dagegen so:
for (a = 1; a <= 10; a++) {
var inp = document.createElement("input");
inp.id = "jj" + a;
inp.value = "JJ";
document.getElementById('aa').append(inp);
}
sieht das Ergebnis im DOM so aus:
html-seminar.de/woltlab/attachment/1286/
Der Wert hat wie gewünscht "JJ" aber im DOM ist davon nichts zu sehen. Das HTML wird beim Einfügen nicht geparst.