JS get value of generated textnode
问题 I have this Javascript in a for loop: renderAElements[i] = document.createElement ("a"); renderAElements[i].setAttribute("href", "#"); renderAElements[i].setAttribute("class", "expander"); renderAElements[i].appendChild(expand); alert (renderAElements[i].nodeValue); where expand is created as: var expand = document.createTextNode("+"); The alert, which is meant to return the link text of each created element returns null. Why is this? 回答1: Because you are trying to get the nodeValue of the