jQuery.uniqueArray = function () {
this.items = new Array();
this.itemsCount = 0;
this.add = function (value) {
if (!this.contains(value)) {
this.items.push(value);
this.itemsCount++;
}
else
throw "The value '" + value + "' allready exists."
}
this.contains = function (value) {
return jQuery.inArray(value, this.items) > -1;
}
this.clear = function () {
this.items = new Array();
this.itemsCount = 0;
}
this.size = function () {
return this.itemsCount;
}
this.isEmpty = function () {
return this.size() == 0;
}
this.remove = function (value) {
if (this.contains(value)) {
var index = jQuery.inArray(value, this.items);
this.items.splice(index, 1);
this.itemsCount--;
}
else
throw "value '" + value + "' does not exists."
}
};
jQuey List (unique)
最新推荐文章于 2025-12-25 09:07:35 发布
本文深入探讨了jQuery的独特数组操作方法,包括添加、查找、清除、获取大小、判断空、移除元素等功能,并通过实例展示了如何高效地进行数组管理。
923

被折叠的 条评论
为什么被折叠?



