Home to write a selector which match an element F
such that F
is parent of E
. More precisely I have a markup:
<div>
<p class="someclass">Some text</p>
</div>
And I need to match div
element which is parent of p.someclass
.
Home to write a selector which match an element F
such that F
is parent of E
. More precisely I have a markup:
<div>
<p class="someclass">Some text</p>
</div>
And I need to match div
element which is parent of p.someclass
.
Not currently possible in CSS. Here is a jQuery function that should do the trick:
$('div > p.someclass').each(function(){
$(this).parent().css('property', 'value');
});
Here is a shorter version of the above example:
$('div > p.someclass').parent().css('property', 'value');