Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVictor Rundbaken
14,037 PointsHow can you traverse up then down?
I know it's simpler to use prev() in this situation but I was trying to figure out other ways to do it.
I was trying:
$("button").click(function(){
$(this).remove();
$(this).parent().children("span").show();
})
But it doesn't show the element.
Can anyone explain how I could do this for future reference?
1 Answer
Victor Rundbaken
14,037 PointsFigured it out! I was deleting the button before I was calling the function on $(this) so it didn't exist anymore.
Correct code is:
$("button").click(function(){
$(this).parent().children("span").show();
$(this).remove();
})