I need assistance finding a jQuery or CSS selector for a specific issue. Here is the code snippet:
<div class="parent">
<div class="grid1">
<p>grids have also p</p>
</div>
<div class="grid2">
<p>grids have also p</p>
</div>
<div class="grid3">
<p>grids have also p</p>
</div>
<p>if this p is present, .grid1 should not have a margin</p>
</div>
<div class="parent">
<div class="grid1">
<p>grids have also p</p>
</div>
<div class="grid2">
<p>grids have also p</p>
</div>
<div class="grid3">
<p>grids have also p</p>
</div>
</div>
Here's what I've already tried:
if($('.parent').has('p')){
console.log(this);
}
However, I am unsure how to target the parent element that contains the 'p'. Can someone help me with this?