<script language="JavaScript">
<!--
function aaa() {
var nodeTr = document.getElementById("tb").childNodes[0];
var nodeTr2 = document.getElementById("tb2").childNodes[0];
var comp = 0;//추가부분
for (var i=0; i < nodeTr.childNodes.length; i++) {
for(var ii=0; ii < nodeTr.childNodes[i].childNodes.length; ii++) {
if(nodeTr.childNodes[i].childNodes[ii].childNodes[0].nodeValue == nodeTr2.childNodes[i].childNodes[ii].childNodes[0].nodeValue) {
comp++;//추가
}
}
}
if(comp == 9){alert('똑같다!!');}//추가및 이동
else{
alert('다르다!!');
return;
}
}
//-->
</script>
<input type="button" value="비교" onClick="aaa()">
<table id="tb" border="1" width="200">
<tr>
<td>2</td>
<td>3</td>
<td>5</td>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<tr>
<td>4</td>
<td>3</td>
<td>6</td>
</tr>
</table>
<table id="tb2" border="1" width="200">
<tr>
<td>2</td>
<td>3</td>
<td>2</td>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<tr>
<td>4</td>
<td>3</td>
<td>6</td>
</tr>
</table>
댓글 없음:
댓글 쓰기