How to select id previously created in JQuery/Javascript? -


i have table created dynamically after ajax return call. once table built need update 1 of elements. if use jquery selector value specified id see undefined in developer tools. here example of table:

var tbl = "<table class='tbldata' id='tblmater'><caption id='numrec'>records: "+numrecs+"</caption><thead><tr><th>code</th><th>sort order</th><th>name</th><th>comment</th><th>active</th><th>edit</th><th>delete</th></tr></thead><tbody>";  for(var i=0; < numrecs; i++){     var jsrec = obj.data[i];     //here build td elements } tbl += "</tbody></table></div>"; 

here example of function test jquery selector:

function test(){   console.log($('#numrec').val()); //i have tried getelementbyid() well. } 

as mentioned above see undefined in console. if knows way how can value table element please let me know. thank you.

val() returns value="" of element. if want text of node want use html() or text() instead.

further more, if want just number, i'd suggest putting span around can target before doing so.


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -