![](/img/trans.png)
[英]How to change Class From jquery but remove that class from another object
[英]How to remove one child from jquery object but not change html
这是我的代码:
$.fn.extend({
del: function() {
}
})
var ds = $(".d");
ds.del(ds[0])
console.log(ds.length)
我希望将jquery.del从jquery childs实现为del child,但不更改html,如何实现呢?
更新
我可以实现var matchDs = ds.del(ds [0]),但我希望从原始jquery对象中删除子代的方法
我发现jquery对象具有#splice func,因此可以使用以下代码:
$.fn.extend({
del: function (e) {
for (var i = 0; i < this.length; i++) {
if (this[i] == e) {
this.splice(i, 1)
}
}
}
})
var ds = $(".d");
ds.del(ds[0])
console.log(ds.length)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.