0

I want to retrieve ALL input type checkbox that are not inside a div that has a class that starts with 'xyz_'

How do I write a css selector for the above?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
user765368
  • 19,590
  • 27
  • 96
  • 167

2 Answers2

3

use div:not([class^="xyz_"]) input[type="checkbox"]{ ... }

see working example http://jsfiddle.net/Sz3zY/

Valli69
  • 8,856
  • 4
  • 23
  • 29
  • Your CSS will not work if `` is not inside any `
    `
    – spatar Jun 07 '12 at 04:57
  • According to the question, targeted `` can be not necessary inside some `
    `, so `` is a valid case not covered by your selector.
    – spatar Jun 07 '12 at 06:20
  • @spatar there is no problem if we use input elements inside div. This fiddle is based on your solution http://jsfiddle.net/Sz3zY/1/ but it doesn't worked for me – Valli69 Jun 07 '12 at 06:29
2
*:not(div[class^="xyz_"]) input[type="checkbox"] { ... }
spatar
  • 550
  • 1
  • 5
  • 15
  • 1
    Note that this will currently only work in jQuery, and is a very fragile solution (like I commented above, it's not trivial even if you use `:not()`). See http://stackoverflow.com/questions/10711730/whats-the-difference-in-the-not-selector-between-jquery-and-css – BoltClock Jun 07 '12 at 04:56
  • @BoltClock, absolutely. I still don't use those fancy selectors much in regular practice :) – spatar Jun 07 '12 at 04:59