Monday, 1 May 2017

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




I have this in my HTML file:




someText

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:



    

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.



http://www.w3.org/TR/selectors4/#subject


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...