In an attempt to customize a list, I have written the following code:
<script>
for (n = 0; n < 3; n++) {
var node = document.createElement("li");
var btn = document.createElement("button");
$("button").css({
'background-color': '#CAC9DB',
'width': '40px',
'height': '40px',
'font-size': '24px',
'font-weight': 'bold'
});
var textnode = document.createTextNode(n);
node.appendChild(btn);
btn.appendChild(textnode);
document.getElementById('list').appendChild(node);
}
</script>
However, I am encountering an issue where the CSS style for buttons is only applying to the first two buttons and not the last one. Can anyone explain why the last button is not being formatted according to the CSS style?