Wednesday 3 January 2018

CSS set style to the parent of class="something" tag

itemprop="text">

I have this in my HTML
file:






someText

class="something">otherText




Is
there a way in CSS I can set the background of the PARENT of the class named something?
In this case, the tag?



Here is my
code:




             type="text/javascript">
function MyMethod(sender, eventArgs) {

if (condition) {
app.set_cssClass("MyClass");
}

$('.MyClass').parent().css('background', 'url(Images/star.png) no-repeat')

}




Answer




At this point,
no.



However, jQuery can do this quite
easily.



$('.something').parent().css('//WHATEVER')



In
the future, CSS4 will be adopting a subject selector, which
would do what you need



$OL >
LI:only-child




The
$ would be used to select the parent or subject of a specific
element.



href="http://www.w3.org/TR/selectors4/#subject"
rel="nofollow">http://www.w3.org/TR/selectors4/#subject



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...