Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有办法从jQuery对象选择中删除项_Javascript_Jquery - Fatal编程技术网

Javascript 有没有办法从jQuery对象选择中删除项

Javascript 有没有办法从jQuery对象选择中删除项,javascript,jquery,Javascript,Jquery,我不确定我在这里是否使用了好的术语,但这就是我想要做的: var selection1 = jQuery('someitems'), selection2 = jQuery('someotheritemswhichcanbethesameornot'); selection2.each(function() { // if this item has some specifications (like a specific value or else), // we do

我不确定我在这里是否使用了好的术语,但这就是我想要做的:

var selection1 = jQuery('someitems'),
    selection2 = jQuery('someotheritemswhichcanbethesameornot');

selection2.each(function() {
   // if this item has some specifications (like a specific value or else),
   // we do something on it and it does not belong in selection1 anymore
   // => can I remove it from selection1 ?
});
我使用jQuery选择了一组项,比如
jQuery('some-items-selected-with-class-or-else'),然后我正在处理其他一组项(其中一些项可以在两个“束”中),如
jQuery('some-other-items-selected-with-class-or-else')

我的问题是:有没有办法从第一个选项中删除第二个选项的某些项目?

如果有帮助的话,我正在使用
jQuery.each()
处理第二个选择的每个项目

这就是我想做的:

var selection1 = jQuery('someitems'),
    selection2 = jQuery('someotheritemswhichcanbethesameornot');

selection2.each(function() {
   // if this item has some specifications (like a specific value or else),
   // we do something on it and it does not belong in selection1 anymore
   // => can I remove it from selection1 ?
});

谢谢

您有两种方法可以做到这一点:

1) 使用以下选项缩小您的选择范围:

2) 使用以下公式减去某些元素:


示例在哪里?在没有看到HTML的情况下,这是一个猜测,但请尝试
$('select.class:not(“.otherclass”)我改变了问题,希望它更容易理解:这不是关于类:)在这种情况下,您可以使用
filter()
,但这取决于您的用例,这是最好的方法。这就是为什么我们要求你的HTML和一个具体的例子的问题。
jQuery('select.general-class').not('.not-you');