title: Get index of the clicked element in knockout
body: <p>What is the best way to get index of clicked element of an unordered list?</p>
  
  <p>Let me provide an example. Say I have the following HTML code:</p>
  
  <pre><code>&lt;ul data-bind="foreach: listItems"&gt;
      &lt;li data-bind="click: $parent.itemClicked"&gt;
           &lt;p data-bind="text: title"&gt;&lt;/p&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Right now I have the following javascript code to get the index:</p>
  
  <p>...</p>
  
  <pre><code>self.itemClicked = function(data, item) {
      var index = $(item.target).index();
  }
  </code></pre>
  
  <p>...</p>
  
  <p>But the problem is the if the target element is <code>&lt;p&gt;</code> for example, I get incorrect result. So how should I get the index of the clicked <code>&lt;li&gt;</code> element? Does knockout have some method for this or I should use jquery in some way?</p>