Side navigation
#8765 closed bug (invalid)
Opened April 04, 2011 06:03PM UTC
Closed April 04, 2011 06:49PM UTC
Last modified April 04, 2011 11:18PM UTC
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.
Attachments (0)
Change History (6)
Changed April 04, 2011 06:05PM UTC by comment:1
owner: | → tomgrohl |
---|---|
status: | new → pending |
Changed April 04, 2011 06:19PM UTC by comment:2
status: | pending → new |
---|
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.
Changed April 04, 2011 06:28PM UTC by comment:3
status: | new → pending |
---|
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.
Changed April 04, 2011 06:46PM UTC by comment:4
status: | pending → new |
---|
Think I must have been doing something wrong. Can't seem to replicate from home. Was working on something at work earlier.
Changed April 04, 2011 06:49PM UTC by comment:5
resolution: | → invalid |
---|---|
status: | new → closed |
Ok, closing for now. Let us know if this needs reopening.
Changed April 04, 2011 11:18PM UTC by comment:6
component: | unfiled → core |
---|
Please provide a test case on http://jsfiddle.net. Doing that vs $('#checkbox').attr("checked", "checked') should have the same results.