Where The Streets Have No Name

table의 행,열,td안의 텍스트 알아내기 본문

Developement/Web

table의 행,열,td안의 텍스트 알아내기

highheat 2006. 3. 29. 18:45
<script>                                                                             
                                                                                   
function window.onload() {                                                           
//행의 개수                                                                                  
alert("table row count : " + document.getElementById("tbl").rows.length);         
//열의 개수
alert("table cell count : " + document.getElementById("tbl").rows[0].cells.length);
//td안의 값
alert("table cell value : " + document.getElementById("tbl").rows[0].cells[0].innerText);
                                                                                   
}                                                                                    
                                                                                   
</script>                                                                            
                                                                                   
<table id="tbl">                                                                     
<tr>                                                                              
    <td>1:sdsds</td>                                                                     
    <td>2:asaa</td>                                                                     
</tr>                                                                              
</table>