DOM之firstChild、lastChild、ChildNodes、parentElement节点操作

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

....................................................................

<script type="text/javascript">
 var test_table = window.document.getElementById("test_table");
 var td_1 = window.document.getElementById("td_1");
 var td_2 = window.document.getElementById("td_2");
 var td_3 = window.document.getElementById("td_3");
 var td_4 = window.document.getElementById("td_4");

 var tdValue1 = td_1.firstChild.innerHTML;
 var tdValue2 = td_2.firstChild.innerHTML;
 var tdValue3 = td_3.firstChild.innerHTML;
 var tdValue6 = td_3.lastChild.innerHTML;
 var tdValue7 = td_3.childNodes[1].nodeValue;
 var tdValue4 = td_4.firstChild.innerHTML;
 var tdValue5 = td_4.innerHTML;
 window.document.write(tdValue1 + "<br />");
 window.document.write(tdValue2 + "<br />");
 window.document.write(tdValue3 + "<br />");
 window.document.write(tdValue4 + "<br />");
 window.document.write(tdValue5 + "<br />");
 window.document.write(tdValue6 + "<br />");
 window.document.write(tdValue7 + "<br />");
 window.document.write("<br />");
</script>

 

原文:http://www.verydemo.com/demo_c101_i88720.html

你可能感兴趣的:(element)