Javascript USES the onclick event to change the color of the selected row

  • 2020-03-30 01:07:54
  • OfStack

HTML page of the table line by line display of div line of course can be set in the mouse up to change its color part of the code as follows


<script type="text/javascript">
var currentActiveRow; //Currently active row
//Change the color of the selected row
function changeActiveRow(obj) {
    if (currentActiveRow) {
        currentActiveRow.style.backgroundColor = "";
    }
    currentActiveRow = obj;
    currentActiveRow.style.backgroundColor = "#F2F2F2";
}
</script>

And I'm going to set the onmousehover or onclick event on td and I'm going to set the onmouseover="changeActiveRow(this)"


Related articles: