Bug Tracker

Modify

Ticket #8765 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 2 years ago by timmywil

  • Owner set to tomgrohl
  • Status changed from new to pending

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

comment:2 Changed 2 years ago by tomgrohl

  • Status changed from pending to 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 2 years ago by timmywil

  • Status changed from new to 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 2 years ago by tomgrohl

  • Status changed from pending to 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 2 years ago by timmywil

  • Status changed from new to closed
  • Resolution set to invalid

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

comment:6 Changed 2 years ago by rwaldron

  • Component changed from unfiled to core

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.