title: javascript: Get value by clicking on current value in loop
body: <p>I am building datatables and by setting up total records in database I have total count of them.</p>
  
  <p>Now I am little confused about click event in JavaScript.
  This is how i am doing this:</p>
  
  <pre><code> for (var cnt = pageno; cnt &lt; pageno + 5; cnt++) {
                  $("#newList").append('&lt;li id="pageno" value=""' + cnt + ' onclick="GetPageno();" &gt; ' + cnt + '&lt;/li&gt;');
              }
  </code></pre>
  
  <p>This is my current loop that will set 5 numbers of list. Now if I want to get value of current list then I am doing this:</p>
  
  <pre><code>function GetPageno() {
          //this.val();
  
  
          alert(document.getElementById('pageno').val());
  
  
      }
  </code></pre>
  
  <p>I have 1 to 5 numbers list on web page. </p>
  
  <p>How do I get value of that number I clicked?</p>
  
  <p>Ex. If I clicked "5", then alert should be coming with value "5", same as for all the list elements.</p>