---
title: "How can I reference a html table cell td from a checkbox inside the cell using jquery?"  
description: "How can I reference a html table cell td from a checkbox inside the cell using jquery?"  
author: "Anonymous User"  
published: 2015-01-20  
updated: 2015-01-20  
canonical: https://www.mindstick.com/forum/12880/how-can-i-reference-a-html-table-cell-td-from-a-checkbox-inside-the-cell-using-jquery  
category: "javascript"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# How can I reference a html table cell td from a checkbox inside the cell using jquery?

I have an [html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) table:

```
  <table>         <tr>              <td>                  <input type="checkbox" name="myCheck">              </td>         </tr>  </table>
```

I want to change the backcolor of the [table cell](https://www.mindstick.com/forum/33993/how-to-wrap-long-text-in-a-table-cell-without-custom-cell) when i [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on the [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net). The table cell doesn't seem to be the [parent](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) of the checkbox.

What is the correct way to get a [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) to the table cell on checkbox click?

## Replies

### Reply by marcel ethan

You can use currently clicked checkbox context this along with .parent() in change event to target the td element:

```
$('input[name="myCheck"]').change(function(){  $(this).parent().css('background',this.checked?"red":"");});
```


---

Original Source: https://www.mindstick.com/forum/12880/how-can-i-reference-a-html-table-cell-td-from-a-checkbox-inside-the-cell-using-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
