I have a table, a datatable to be precise. Which is getting created, I have Computer Names in the first columns and prices on all the columns after. I am using the jquery plug in jquery.dataTables.editable and jquery.jeditable.
Here is a simple diagram to prove my point.
Column 1 | Column 2
--------------------
Apples | 44%
--------------------
Bananas | 23%
--------------------
Oranges | 13%
--------------------
Other | 10%
--------------------
The actual elements do not have a class associated with them. I need to get ONLY column 1 elements to have a class of “read_only”
This table is dynamically generated so it needs to happen in javascript.
This is what I was trying
$('tr').each(function(){
if($("tr:first-child")){
$(this).attr("class", "read_only");
}
});
This was in the $(document).read(function(){}, after I initialize my datatable.
Any suggestions on what I need to do?
If you are using datatables it’s easy to add class during initialization like this: