테이블 줄 순서 바꾸기

에.. 그러니깐

<tr></tr>이 이동 되는거랄까요??


<script>

var prev = null;

function getRowIndexFromId(obj)
{
for (i=0;i<oTable.rows.length;i++) if (oTable.rows[i].id==obj) return i;
}

function selectCell(obj)
{
obj = getRowIndexFromId(obj);
if (prev!=null) oTable.rows[prev].style.backgroundColor = "";
prev = obj;
oTable.rows[prev].style.backgroundColor = "#f7f7f7";
}

function moveCell(direc)
{
var next = prev + direc;
if (next==oTable.rows.length) next = 0;
else if (next==-1) next = oTable.rows.length - 1;
oTable.moveRow(prev,next);
prev = next;
}

</script>

<table width=100 id=oTable border=1>
<tr id=tr_0 onclick="selectCell(this.id)"><td>바나나</td></tr>
<tr id=tr_1 onclick="selectCell(this.id)"><td>사과</td></tr>
<tr id=tr_2 onclick="selectCell(this.id)"><td>딸기</td></tr>
</table>

<a href="javascript:void(0)" onClick="moveCell(-1)">위로</a><br>
<a href="javascript:void(0)" onClick="moveCell(1)">아래로</a>
Posted by 알 수 없는 사용자
,