closest(class) needs to be a cookie's name

closest(class) needs to be a cookie's name

I'm dynamically assigning tables as data1, data2, data3, yadda yadda.  Inside these tables, I need a function that grabs the closest table's class, so I can assign it as the cookie name.

So in theory, I should be able to go inside data2, click on this function, get a data2 cookie, and ta dah.

I'm hoping the solution to this problem will provide insight to how I can assign the cookie value, but right now, I'm just focusing on the name.

How would I grab the closest table's class?

I've tried $(this).closest("p").class.val() and other combinations...