什么是var $ removable = $ container.find(selector)的倒数;?

时间:2012-07-31 13:58:49

标签: jquery

我试图选择所有不是'选择器'的元素。

喜欢的东西

var $removable = $container.find(.not(selector));

var $removable = $container.find(.not(selector)); 但我知道语法错了。 有人可以帮忙吗? 感谢

2 个答案:

答案 0 :(得分:3)

你可以试试这个:

var $removable = $container.find(':not('+ selector +')');

var $removable = $container.find('some_selector').not(selector);

来自@Mattias comment

$container.find('some_selector:not('+selector+')'

答案 1 :(得分:0)

使用not selector

这很简单
$('div').not('#selector').css('background-color', 'red');​

live example。上面的示例假设您要查找不是id为'selector'的元素的div元素。