Getting cell class name

Getting cell class name

shashi3989shashi3989 Posts: 1Questions: 1Answers: 0

Hey ,,,

I have assigned class name 'x' like <td><span class="X"></span></td> for multiple rows in java script. Now data is loaded in jquery Datatables, i want get all the rows with class name 'x'.

Answers

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    You'll probably need a loop to find all spans with class X and then find the parent rows. In jquery like:

    $(document).ready(function(){
        $('span.X').each(function(index){
            var myRow = $(this).closest('tr');
            //Do something with myRow !!!
            myRow.attr('bgColor', 'yellow');
        });
    });
    

    See working example in JSFiddle

This discussion has been closed.