プラグイン内の each() ループから要素を削除したいので、特定の itens のみを返します。しかし、これまでに多くのテストを行いましたが、まだアイテムを削除できません。
(function($){
$.fn.teste = function(parametro){
var parametro_padrao = {};
if (parametro){$.extend(parametro_padrao, parametro);}
return this.each(function(){
//if certain condition happens I want to remove an element so it will not be returned in the "return" clause above
});
};
})(jQuery);
編集:
:hidden または :visible は、悪い考えであると思われるオフセットを使用するため、適切ではありません。
しばらくして、私は素晴らしい解決策を見つけました。他の人が私のように時間を無駄にしないように共有します。
(function($){
$.fn.visivel = function(parametro){
var parametro_padrao = {};
if (parametro){$.extend(parametro_padrao, parametro);}
elemento = this;
this.each(
function(index){
$(this).parents().andSelf().each(
function() {
if ( ($(this).css("display") == "none") || ($(this).css("visibility") == "hidden") ) {
delete elemento[index];
return false;
}
}
);
}
);
return elemento;
};
})(jQuery);