javascript - How to select elements from previous div that have the same position inside parent -


<ul class="user-text">   <li class="user-text">user 1 text</li>   <li class="user-text" style="display:none">user 2 text</li>   <li class="user-text" style="display:none">user 3 text</li>   <li class="user-text" style="display:none">user 4 text</li> </ul>  <ul class="user">   <li class="user">user 1 image</li>   <li class="user">user 2 image</li>   <li class="user">user 3 image</li>   <li class="user">user 4 image</li> </ul> 

i think works similar image slider. want achieve : on "user 2 image" : hover -- set "user 2 text" : display visible (hide other user texts). same if hover on other "user image". cannot figure out how match position each div.

all welcome. thank you.

if duplicate, please point resolved situation.

you can use:

$('li.user' ).hover(function(){   $('li.user-text:eq('+$(this).index()+')').show().siblings().hide(); }); 

working demo


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -