tags:

views:

286

answers:

1

I'm using jQuery 1.3.1 and when I try to loop through a form and remove any div w/out an id i get an exception.

uncaught exception: Syntax error, unrecognized expression: [@id]

$('form:eq(1)').children().each(
        function()
        {
            this2 = this;
            if ($(this2).find('div').not('[@id]')) { $(this).remove(); }
        }
    );
+5  A: 

The @ operator has been deprecated for a while and finally removed in version 1.3. Just remove it from the attribute declaration:

.not('[id]')...

EDIT: The following should do what you stated, as opposed to your original code:

if($(form).find('div').filter(function(){ 
     return $(this).attr('id') == '';
}).remove();
Eran Galperin
I realized after I got this working that the above removes all the childen(if any of the children don't have an id attr), how can I remove ONLY the div elements that don't have an id from that form i'm looping through?
Toran Billups
I suggested an alternative method
Eran Galperin