Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are calling <code>val()</code> on <code>li</code> which is not correct, you can use .attr("value") it would be better if you use <a href="http://api.jquery.com/data/" rel="nofollow">data()</a> attributes e.g data-someattributeName to make it more clear. You are assigning same id to more then one elements which is not legal. Assign a class to them and bind event with class and you will be able to get the required attribute.</p> <p><em>Add class to li element when you create them, you are not assigning <code>cnt</code> to <code>value</code> properly and assigning empty string to value</em></p> <pre><code>for (var cnt = pageno; cnt &lt; pageno + 5; cnt++) { $("#newList").append('&lt;li id="pageno" class="pageno" value=""' + cnt + ' onclick="GetPageno();" &gt; ' + cnt + '&lt;/li&gt;'); } </code></pre> <p><em>Bind click event using <a href="http://api.jquery.com/class-selector/" rel="nofollow">class selector</a></em></p> <pre><code>$(".pageno").click(function() { alert($(this).attr('value')); }) </code></pre> <p><strong><a href="http://jsfiddle.net/aKMHD/" rel="nofollow">Live Demo</a></strong>, using <a href="http://api.jquery.com/data/" rel="nofollow">data()</a> and class selector. Here I have also assigned <strong>unique</strong> <code>Ids</code> to <code>pageno</code>.</p> <pre><code>pageno = 1; for (var cnt = pageno; cnt &lt; pageno + 5; cnt++) { $("#newList").append('&lt;li id="pageno"'+cnt+' class="pageno" data-custom="' + cnt + '" onclick="GetPageno();" &gt; ' + cnt + '&lt;/li&gt;'); } $(".pageno").click(function() { alert($(this).data('custom')); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload