2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Target the Parent of an Element Using jQuery
|
|
|
|
---
|
|
|
|
## Target the Parent of an Element Using jQuery
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
2019-03-02 02:03:52 +05:30
|
|
|
```html
|
2018-10-12 15:37:13 -04:00
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#target1").parent().css("background-color", "red"); // Selects the parent of #target1 and changes its background-color to red
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
```
|