Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140071

Table Data Grouping For Each Row

$
0
0

I am very new to JavaScript and would like to have table data grouped for each row. Each row has 6 table data. I would like the first 3 linked together and the last 3 separate. Creating a className for the columns I want linked together makes all of the tables hover. I would only like the specific row values to be hoverable.

var table = document.getElementsByTagName("tbody");

for (var i = 0; i < table.length-1; i++){

    var currentTable = table[i];
    var rows = currentTable.getElementsByTagName("tr");

    for(var j = 3; j < rows.length-1; j++){

        var c = rows[j].cells;

        c[0].className = "fall";
        c[1].className = "fall";
        c[2].className = "fall";
        // for each row make these three selectable

        c[3].className = "spring";
        c[4].className = "spring";
        c[5].className = "spring";
    }
}

I am not sure if there is a better way to do this other than creating a new class name for each row. If I need to do that, is there an easy way to do that dynamically? Please let me know if you'd like to see the actual table. Thank you.


Viewing all articles
Browse latest Browse all 140071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>