Jump to content


Photo

jQuery


  • Please log in to reply
4 replies to this topic

#1 Jeeves

Jeeves

    I write the interwebz

  • Members
  • 4,156 posts
  •  Friendly neighborhood standards Nazi

Posted 27 June 2010 - 12:54 PM

I have a togglable list, for which I am attempting to animate the contents.
When you click the header (this), it toggles the next list, for which I want to animate the list items. If I use a selector such as $('li') the function works, but I can't figure out how to get it to work with the object chain below.
var elems = $('this').next('ul').children('li'), i = 0;
(function flyIn(){
	$(elems[i++]).animate({'left': '+=200px'},100, flyIn);
})();
Ideas?

World Domination Status: 2.7%


#2 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 27 June 2010 - 11:10 PM

Does it just not work or are you getting any errors? Either way "$('this')" looks wrong, should probably be "$(this)"
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#3 Jeeves

Jeeves

    I write the interwebz

  • Members
  • 4,156 posts
  •  Friendly neighborhood standards Nazi

Posted 28 June 2010 - 03:46 AM

You're right there, but I've fixed that too. Its just not working, no errors logged.
If I have something like

$('li') instead of $('this').next('ul').children('li') it works, still no error. But I specifically want to select only the children of the next list, not every item

World Domination Status: 2.7%


#4 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 28 June 2010 - 09:26 AM

Time to debug. For each step, verify that the correct thing is returned, meaning for
$('this') and
$('this').next('ul') and then
$('this').next('ul').children('li')
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#5 Jeeves

Jeeves

    I write the interwebz

  • Members
  • 4,156 posts
  •  Friendly neighborhood standards Nazi

Posted 28 June 2010 - 12:00 PM

Aha! Got it working. Same code, but enclosed differently -.-
Cheers for the help. Funnily enough I only changed how it was being called because I was testing the steps again and made a mistake the line above and thought it could be done better!

World Domination Status: 2.7%





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users