javascript - getElementById not finding element -


i using jquery count dynamically generated list items , in array - getting initial values of objects like:

 $(document).ready(function () {      $("<div></div>").load("/stats/contents #stats", function () {          statcount = $(".list-group-item", this).length;          (var j = 0; j < statcount; j++) {              statlist.push(stat);          }          (var = 0; < statcount; i++) {              statlist[i].statid = document.getelementbyid("statid-" + (i + 1)  ).value;              statlist[i].productdescription = document.getelementbyid("producttype-" +                   (i + 1)).value;              statlist[i].lastmeasuredinventoryamount = document.getelementbyid              ("statlastmeasureamount-" + (i + 1)).value;          }     )} )} 

i got 2 issues here: 1) when using $('').load("/stats/contents #stats", function () { above, doesn't find element unless browser refreshed.

2) changed -
$('').on("load","/stats/contents #stats", function () {
after changing, issue #1 fixed. - doesn't count using statement inside function: statcount = $(".list-group-item", this).length;

any ideas how make both work? thanks


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -