title: how to find index of nested element in jquery?
body: <p>I want to find the index of the <code>p</code> element with id <code>tea2</code> with reference to its parent <code>div</code> element.</p>
  <p>For example, the id <code>tea2</code> index should be <code>1</code> as reference to parent <code>div</code> element. Note: I have to omit these &quot;br&quot; tags in indexing.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let index = $('#tea2').index();
  console.log(index);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class=""&gt;
    &lt;p&gt;Milk&lt;/p&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;p class="hot" id="tea"&gt;Tea&lt;/p&gt;
    &lt;p class="hot" id="favorite"&gt;Coffee&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=""&gt;
    &lt;p&gt;Milk&lt;/p&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;p class="hot" id="tea2"&gt;Tea&lt;/p&gt;
    &lt;p class="hot" id="favorite2"&gt;Coffee&lt;/p&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>