Add class to cell/row on condition

[ad_1]

Hi, I have previously used this:

{
	"wpda_search_force_enter": false,
	"columnDefs": [{
		"targets": [1, 3],
		"visible": false,
		"searchable": false
	}, {
		"targets": [7],
		"className": "dtCol_lessonStatus",
		"render": "function(data) { if (data == 'upcoming') return '<span class=\"dtCell_statusUpcoming\">' + data + '</span>'; if (data == 'active') return '<span class=\"dtCell_statusActive\">' + data + '</span>'; if (data == 'expired') return '<span class=\"dtCell_statusExpired\">' + data + '</span>'; }"
	}]
}

But rather than create class in span in the cell, I want to have the cell have the class intead. This is my attempt, but they aren’t working. What have I done wrong?

{
	"wpda_search_force_enter": false,
	"columnDefs": [{
		"targets": [1, 3],
		"visible": false,
		"searchable": false
	}, {
		"targets": [7],
		"className": "dtCol_lessonStatus",
		"createdCell": "function(td, cellData, rowData, row, col) { if (cellData == 'upcoming') $(td).addClass('dtCell_statusUpcoming'); if (cellData == 'active') $(td).addClass('dtCell_statusActive'); if (cellData == 'expired') $(td).addClass('dtCell_statusExpired'); }"
	}],
	
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer