求解:运行出来为什么不显示第一个子结点和最后一个子结点的值?为什么第一个子结点名字显示不是TEXT,最后一个子结点名字显示不是BUTTON?最后一个结点的类型明明是按钮,但检测到是文本(类型值为3)?
<form action="#" name="form1" id="form1">
<input type="text" name="txt" id="txt" value="value_text_input"><br>
<input type="button" name="button" id="button" value="value_btn"><br>
<button type="submit" id="btn_submit">提交按钮</button>
</form>
var node_form= document.getElementById("form1");
document.write("打印表单1的第一个子元素的各个属性: ");
document.writeln(node_form.firstChild);
document.writeln(node_form.firstChild.nodeName);
document.writeln(node_form.firstChild.nodeType);
document.writeln(node_form.firstChild.nodeValue);
document.write("<br>打印表单1的最后一个子元素的各个属性:");
document.writeln(node_form.lastChild);
document.writeln(node_form.lastChild.nodeName);
document.writeln(node_form.lastChild.nodeType);
document.writeln(node_form.lastChild.nodeValue);
打印表单1的第一个子元素的各个属性: [object Text] #text 3
打印表单1的最后一个子元素的各个属性:[object Text] #text 3
运行结果见最后一张图