I have a table where each row has a CSS id like this:
...
...
..
-
2020-12-10 10:30
Use closest:
$(".anotherclass").click(function() {
console.log($(this).closest("tr").attr("id"));
});
From the docs:
Get the first element that matches the selector, beginning at the
current element and progressing up through the DOM tree.