Question: I have an element that is inside a table somewhere.
I need to get his tbody element.

How can I do that?

Tried `$(this).closest('tbody')`

But it looks like it did not work..

My code:

```
$("table").on('click', ['td'], function(event) {

    if ($(this).hasClass('uneditable')) { return; }
    // here I need to check the tbody element
    console.log($(this).closest("tbody"))
    }

```

Maybe I am doing this wrong, because I want to apply this function only if a click on a table with specific classes for elements:

* table - `dattable`
* tbody - `editabe`
* td - not `uneditable`

Thanks !

Answer: 
So just bind click to the tbody that has the class and check the class on click.

```
$("table.dattable tbody.editable").on("click", "td:not(.uneditable)", function(){});

```

Or id the .editable is dynamic on the table than move it to the other selector

```
$("table.dattable").on("click", "tbody.editable td:not(.uneditable)", function(){});

```
Use `:not()`

```
$("table").on('click', 'td:not(".uneditable")', function(event) {

});

```

FYI, don't forget to replace `['td']` with `td`

```js
console.log($('#a1').closest('tbody').length)
$("table.datatable").on('click', 'td:not(".uneditable")', function(event) {
  console.log($(this).closest("tbody.editable").length)
});
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>1st table</h1>
<table class="datatable">
  <tbody class="editable">
  <tr>
    <td class="uneditable"><div id="a1">ABC</div></td>
    <td class="uneditable"><div id="a1">XYZ</div></td>
    <td><div id="a1">PQR</div></td>
  </tr>
  </tbody>
</table>
<h1>2nd table</h1>
<table class="datatableNot">
  <tbody class="editable">
  <tr>
    <td class="uneditable"><div id="a1">ABC</div></td>
    <td class="uneditable"><div id="a1">XYZ</div></td>
    <td><div id="a1">PQR</div></td>
  </tr>
  </tbody>
</table>
```