title: checking if the user clicked on href after a JQuery modify
body: <p>I am trying to check if a user clicked on a kind of a href in a specific class.</p>
  
  <p>I am appending the class in jquery because I need to put a different link every time</p>
  
  <pre><code>$("#list-dir").append("&lt;a href='' class='add-href'&gt;&lt;il class='dir-items'&gt; " + dir_items[i] + " &lt;br&gt; &lt;/il&gt;&lt;/a&gt;")
  $(".add-href").eq(i).attr("href", href_element);
  </code></pre>
  
  <p>and it works as it should I can see the class and the correct link in the HTML file. But when I try to check if the user clicks it nothing works for some reason like the class isn't there
  <a href="https://i.stack.imgur.com/xlm1O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xlm1O.png" alt="enter image description here"></a></p>
  
  <p>This ^ was how the webpage looks after I modified it with JQuery.</p>
  
  <p>I already tried putting this code: </p>
  
  <pre><code>$(document).ready(function(){
   $(".add-href").on("click", function(e){
      console.log("d")
  
    });
  });
  </code></pre>
  
  <p>as most of the answers suggest but it didn't work.</p>