title: How to know which section li has been clicked using jquery?
body: <p><strong>Info</strong>: I have two sections in dropdown menu. one is <code>id=&quot;copy&quot;</code> second is  <code>id=&quot;move&quot;</code> i just want to know which section of <code>li</code> has been clicked! i want to performs this action in a single function insteed of two functions!</p>
  <p><strong>Problem</strong>: The <code>const copy</code> is working fine in console.log but <code>const move</code> is not working it's getting null in console.log.</p>
  <p><strong>html</strong></p>
  <pre><code>&lt;div class=&quot;btn-group&quot; data-id=&quot;25&quot;&gt;
      &lt;button data-toggle=&quot;dropdown&quot; class=&quot;btn btn-default btn-xs dropdown-toggle waves-effect waves-themed&quot;
          aria-expanded=&quot;false&quot;&gt;&lt;span class=&quot;caret&quot;&gt;&lt;/span&gt;&lt;/button&gt;
      &lt;ul class=&quot;dropdown-menu dropdown-menu-right&quot;&gt;
          &lt;li class=&quot;dropdown-submenu&quot;&gt;
              &lt;a href=&quot;javascript:void(0);&quot; tabindex=&quot;0&quot; data-toggle=&quot;dropdown&quot;&gt;Copy
                  to &lt;span&gt;»&lt;/span&gt; &lt;/a&gt;
              &lt;ul class=&quot;dropdown-menu dropdown-menu-right&quot; id=&quot;copy&quot;&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;6&quot; href=&quot;javascript:void(0);&quot;&gt;Alert&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;5&quot; href=&quot;javascript:void(0);&quot;&gt;Breaking&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;3&quot; href=&quot;javascript:void(0);&quot;&gt;Technology&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;2&quot; href=&quot;javascript:void(0);&quot;&gt;Schemas Inc.&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;1&quot; href=&quot;javascript:void(0);&quot;&gt;Crime&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li class=&quot;dropdown-submenu&quot;&gt;
              &lt;a href=&quot;javascript:void(0);&quot; tabindex=&quot;1&quot; data-toggle=&quot;dropdown&quot;&gt;Move
                  to &lt;span&gt;»&lt;/span&gt;&lt;/a&gt;
              &lt;ul class=&quot;dropdown-menu dropdown-menu-right&quot; id=&quot;move&quot;&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;6&quot; href=&quot;javascript:void(0);&quot;&gt;Alert&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;5&quot; href=&quot;javascript:void(0);&quot;&gt;Breaking&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;3&quot; href=&quot;javascript:void(0);&quot;&gt;Technology&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;2&quot; href=&quot;javascript:void(0);&quot;&gt;Schemas Inc.&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a tabindex=&quot;0&quot; data-action=&quot;1&quot; href=&quot;javascript:void(0);&quot;&gt;Crime&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>JQuery</strong></p>
  <pre><code>$(&quot;.dropdown-menu #copy,.dropdown-menu #move&quot;).on(&quot;click&quot;, &quot;li a&quot;, function (e) {
          const copy = $('#copy');
          const move = $('#move');
  
          if (copy) {
              console.log('copy')
          } else if (move) {
              console.log('move')
          }
      });
  </code></pre>