Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8765 closed bug (invalid)

jQuery.each loops over jQuery methods as well as elements array

Reported by: tomgrohl Owned by: tomgrohl
Priority: undecided Milestone: 1.next
Component: core Version: 1.5
Keywords: Cc:
Blocked by: Blocking:

Description

I noticed when using .each on an element (and only an element) it also loops over jQuery methods as well.

So doing something as simply as:

    $("#checkbox").each(function(){
   
        $(this).attr("checked","checked");
    });

will go over any elements it finds as well as any jQuery methods/properties such as slideToggle for example.

I don't know if this is deliberately like this but it doesn't seem right to me.

Any clarification would be great.

Change History (6)

comment:1 Changed 9 years ago by timmywil

Owner: set to tomgrohl
Status: newpending

Please provide a test case on http://jsfiddle.net. Doing that vs $('#checkbox').attr("checked", "checked') should have the same results.

comment:2 Changed 9 years ago by tomgrohl

Status: pendingnew

Sorry should have said, its not whats passed to the .each function, its how .each works.

Within .each internally I added some console.log to output the name of the element it was on, but it was also outputting jQuery method names.

comment:3 Changed 9 years ago by timmywil

Status: newpending

Sorry, gotta throw this back at you again. I am unable to reproduce the described behavior. http://jsfiddle.net/timmywil/Y83Qe/1/ It would be very helpful if you could provide a test case that demonstrates what you're talking about.

comment:4 Changed 9 years ago by tomgrohl

Status: pendingnew

Think I must have been doing something wrong. Can't seem to replicate from home. Was working on something at work earlier.

comment:5 Changed 9 years ago by timmywil

Resolution: invalid
Status: newclosed

Ok, closing for now. Let us know if this needs reopening.

comment:6 Changed 9 years ago by Rick Waldron

Component: unfiledcore
Note: See TracTickets for help on using tickets.