使用JQuery,如何选择没有类的所有元素

时间:2012-07-16 01:45:18

标签: javascript jquery

  

可能重复:
  jQuery get all divs which do not have class attribute

我需要选择没有定义类的所有元素。我如何使用JQuery做到这一点?

2 个答案:

答案 0 :(得分:5)

$(':not([class])')

但请注意,如果他们没有课程,也会选择html, body, head

答案 1 :(得分:4)

此查询将选择所有元素,然后过滤那些没有class属性的元素:$('*').not('[class]')