Search code examples
jquerycsscss-selectorspseudo-class

:has Selector in CSS doesn't allow specificity


When using the css selector :has I'm only allowed to put basic properties such as tag name:

.field:has(input)

But not:

.field:has(input[type="checkbox"])

Why is this? I want to select the element of class field, NOT the input.


Solution

  • :has isn't a selector in CSS - you are talking about jQuery.

    Use: $('.field:has(input[type="checkbox"])');

    Working jsFiddle here