解决方法
如果你正在谈论从jQuery对象中删除节点,使用过滤器或不是函数。
See here for more。
如何使用过滤器:
- var ps = $('p');
- //Removes all elements from the set of matched elements that do
- //not match the specified function.
- ps = ps.filter(function() {
- //return true to keep it,false to discard it
- //the logic is up to you.
- });
要么
- var ps = $('p');
- //Removes all elements from the set of matched elements that
- //do not match the specified expression(s).
- ps = ps.filter('.selector');
如何使用不:
- var ps = $('p');
- //Removes elements matching the specified expression
- //from the set of matched elements.
- ps = ps.not('.selector');