How to get the next Li data value with jquery?

advertisements
<ul>
  <li class="x active" data-title="a"></li>
  <li class="x" data-title="b"></li>
  <li class="x" data-title="c"></li>
  <li class="x" data-title="d"></li>
</ul>

<button id="btn1">Click me to get next data-title</button>

if current active li has data-title of "a", how do i get the next li's data-title which is "b"?


$("#btn1").click(function() {
    var next_data_title = $('li.active').next('li').attr('data-title');
    alert(next_data_title);
});