改變選中行的顏色

html頁面的table 中一行一行的顯示當然 div也行 可設置在鼠標放上去時改變其顏色 部分代碼如下


<script type="text/javascript">
var currentActiveRow; //當前活動行

//改變選中行的顏色
function changeActiveRow(obj) {
    if (currentActiveRow) {
        currentActiveRow.style.backgroundColor = "";
    }
    currentActiveRow = obj;
    currentActiveRow.style.backgroundColor = "#F2F2F2";
}

</script>

然後在td上設置onmousehover或者onclick事件即可 οnmοuseοver="changeActiveRow(this)"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章