I am dynamically creating a "div" element and a checkbox. If my code does not contain the div.innerHTML += '<br>'
line (or any other line for that matter) as below, the logic setting the checkbox to true works properly. However, if I include the said line, the checkbox is not set to true, even if the data is true. Why would having this additional line create issues?
div = document.createElement('div')
var checkbox = document.createElement('input')
checkbox.type = 'checkbox'
if (data === true) {
checkbox.checked = true
} else {
checkbox.checked = false
}
div.appendChild(checkbox)
div.innerHTML += '<br>' // Line creating issues
divArea.appendChild(div)