Home » Javascript » how check position of clicked <li> with another inner ul <li>

how check position of clicked <li> with another inner ul <li>

Posted by: admin June 30, 2018 Leave a comment

Questions:

I have ul with two inner li. I want to get the position of of the first li
but it counts all of the li

$("#clicked_job li").click(function() {
  var index = $(this).index();
  alert(index);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul id="clicked_job">
  <li>
    <ul>
      <li></li>
      <li></li>
    <ul>
  </li>
  <li>
    <ul>
      <li></li>
      <li></li>
    <ul>
  </li>
</ul>
Answers: