As above, you can do that quite easily with jquery but not with css alone.
Alternatively, depending on what you're trying to do, you could probably just apply the styling directly to your p. It's a block element by default anyway, just like the div.
var parentDiv = $(".hlight").parent();
^ way to read the whole thread.
Probe is however right though, that the easiest way to achieve this is to put a class on your parent DIV. If you're unable to do this and need to use jquery, the selector is
Code:var parentDiv = $(".hlight").parent();
I have the following HTML
<div>
<p class="hlight">text</p>
</div>
<div>
<p>text</p>
</div>
In my css, i would like if
div p.hlight {
style the div and NOT the p
}
can this be done?
<div class='highlightChildPs'>
<p>Some text</p>
</div>
div.highlightChildPs p
{
// style rules
}
I suspect it's because he's got no way of changing the markup. At least I hope so!why can't you do [code suggestion]
why can't you do
Code:<div class='highlightChildPs'> <p>Some text</p> </div> div.highlightChildPs p { // style rules }
$(document).ready(function() {
$("p.hlight").parent().addClass("hlightcontainer");
});