You can add elements to a jQuery object simply using

$('originalobject').add('#someid').add('.someclass').add($
('anotherobject')).add(node);

and remove with the filter() function:

var unwanted = $('unwanted');

$('wanted').filter(function(i){
    for (var n=0,nl=unwanted.length; n<nl; n++){
        if (this == unwanted[n]) return false;
    } return true;
});

On Nov 26, 9:26 am, takeshin <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Using hints from this group, I create set of invalid fields this way:
>
> jQuery.fn.push = function( selector_or_nodes ) {
>                                           //  Given a selector or a jQuery 
> object, append all of the
> nodes to
>                                           // the current jQuery object.
>                                           var nodes = (typeof a == 'string') ?
>                                           $( selector_or_nodes ) : 
> selector_or_nodes;
>                                           var node_count = nodes.length;
>                                           for( var i = 0; i < node_count; i++ 
> ) {
>                                                   this[ this.length++ ] = 
> nodes[ i ]
>                                           };
>
>                                   };
>
> $.extend({
>                                                    validation: {
>                                                            invalidFields: 
> $([]),
>
>                                                            addInvalidField: 
> function(field) {
>                                                                    
> this.invalidFields.pushIf($(field));
>                                                            }
>
> }
> });
>
> // code here...
> $.addInvalidField($('#myid1'));
> // more code here...
> $.addInvalidField($('#myid2'));
>
> How to remove object from $.validation.invalidFields?
>
> I'm trying to do it like this:
>
> jQuery.fn.removeIf = function(selector_or_nodes) {
>                                           //  Given a selector or a jQuery 
> object, removes all of the
> nodes from
>                                           // the current jQuery object.
>                                           var nodes = (typeof a == 'string') ?
>                                           $(selector_or_nodes) : 
> selector_or_nodes;
>                                           for (var i = 0; i<this.length; i++) 
> {
>                                                   for (var j=0; 
> j<nodes.length;j++) {
>                                                           if 
> (this[i]==nodes[j]) {
>                                                                   // REMOVE 
> THIS ELEMENT HERE
>                                                           }
>                                                   }
>                                           }
>                                   };
>
> I managed to determine if object exist in that set,
> but how to remove it?
>
> --
> regards,
> takeshin

Reply via email to