I
I
Igor Kaspersky2015-10-14 18:34:24
JavaScript
Igor Kaspersky, 2015-10-14 18:34:24

How to display text in each list using jquery?

Hello. I have a list in my code

<ul>
 <li>
  <span class="main">Клик</span>
  <span class="nline">.....</span>
 </li>
 <li>
  <span class="main">Клик</span>
  <span class="nline">.....</span>
 </li>
</ul>

how to write in jquery in one line so that it is displayed one by one, i.e. clicked on 2 list text got out from the 2nd. I can’t find it on the Internet, there is about a selective choice). I tried it myself, but I either have all or not one
$('.nline').hide();

  $('.main').on('click', function(i){
    // $(this).addClass('lidown');
    $('.nline').eq(i).slideToggle();
  });

And I also added a picture via list-style: i.e. open list, closed list (triangle) and also I can’t either through jquery
li {
  list-style: url('img/Up.png');
}
.lidown{
  list-style: url('img/down.png');
}

What to do with 2 problems?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-10-14
@HHabar

$('ul').on('click', '.main', function(i){
  $(this).next('.nline').slideToggle();
});

random accidents

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question