#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 12 years ago by
Owner: | set to tomgrohl |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
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.
comment:3 Changed 12 years ago by
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.
comment:4 Changed 12 years ago by
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.
comment:5 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Ok, closing for now. Let us know if this needs reopening.
comment:6 Changed 12 years ago by
Component: | unfiled → core |
---|
Please provide a test case on http://jsfiddle.net. Doing that vs $('#checkbox').attr("checked", "checked') should have the same results.