title: JQuery addClass not working on anchor tag on click event
body: <p><code>addClass()</code> is not working on jQuery on click event. My code looks like this.</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>init: function () {
        ShareData.config.pageNo = 1;
        ShareData.ajaxCall();
        $(document).on('click', 'ul#pagination li a', function () {
            ShareData.config.pageNo = $(this).text();
            ShareData.ajaxCall();
            $("ul#pagination li a.clickedLink").removeClass("clickedLink");
            $(this).addClass('clickedLink');
        });
    },
    
  var pageLink = "";
  for (var i = 1; i &lt;= totalPage; i++) {
      if (i == 1) {
          pageLink += "&lt;li&gt;&lt;a href='#' class='clickedLink'&gt;" + i + "&lt;/a&gt;&lt;/li&gt;";
      } else {
          pageLink += "&lt;li&gt;&lt;a href='#' class=''&gt;" + i + "&lt;/a&gt;&lt;/li&gt;";
      }
  }
  document.getElementById('pagination').innerHTML = pageLink;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.pagination ul li a.clickedLink {
      background-color: #BBB;
  }
  
  .pagination ul li a{
      color: #000;
      height: 24px;
      line-height: 24px;
      width: 24px;
      text-align: center;
      display: inline-block;
      text-decoration: none;
      border: 1px solid #000;
      background: #FFF;
      text-shadow: none;
  }
  .pagination ul li {
      float: left;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="pagination"&gt;
      &lt;ul id="pagination"&gt;
      &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And output is like this</p>
  
  <p><a href="https://i.stack.imgur.com/ntyLN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntyLN.png" alt="html table with pagination"></a>
  Everything is working fine on load while, i need to change the background of recently clicked anchor tag.</p>