Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果他的孩子有某个班级,我如何将css应用于父母?
例如:
<p> <span class="validationMessage">Last Name is required field</span> </p>
我想基于他的子元素具有名为“validationMessage”的类来给出 p 标签 css
尝试:has选择器:
:has
$("p:has(span.validationMessage)").css(yourPCss);
看看:http: //jsfiddle.net/jdfcr/
.parent()
$('span.validationMessage').parent().css(style);
也看看
.hasClass()