Get parent and first span child jQuery

jquery

Solution

You need jquery siblings(),

Live Demo

$('.like').siblings('span:first').text();

Problem

I have this structure: ``` <div class="list"> <ul> <li> <span class="number">1</span> <p class="list-title"><a href="#">Welcome</a></p> <img src="images/like.png" class="like" /> <div class="subcomments"> <div class="comments"> <ul> <li> <span class="number">2</span> <img src="images/like.png" class="like" /> </li> </ul> </div> </div> </li> </ul> ``` And I want when click on the class "like" appears the content of span.number, i.e. goes to the father and gets the content of the span with class number. I'm trying this: ``` $('.like').parent().children('span:first').text() ``` But always gives me 1 in the two situations, instead of giving 1 in the first like, and 2 in the second like.

Original source