jQuery selector and its element order
Posted in XHTML / JavaScript / CSS on June 15th, 2009 by Thomas – Be the first to commentThis issue applies to jQuery 1.2.6. It might have been fixed in later versions.
I experienced this in a script where I made a selection of list-elements allocated in a variable that I wanted to work with. I used hide(), and show() and the selector :first and :last. When I hide and then showed an element it suddenly moved to the end of the list when it originally was at the beginning of the list. When I then used :first to point to the first element, I got the second because it had moved. To solve this I had to do the selection over again instead of using the variable holding the selection. So don’t use a variable to hold your selection when you want to use :first and :last. Do a new selection instead.
