html - How to append a button when already appending a row in javascript -


i appending row in html table using java script. need append button 1 of table data of row. button should have on click event well. how so? cant results out previous answers please help. below code.

$(document).ready(function () {          $.ajax({              url: '/api/userapi/',              type: 'get',              contenttype: "application/json;charset=utf-8",              datatype: "json",              success: function (data) {                                  alert('user added successfudly');                    (var = 0; < data.length; i++) {                           $("#absa").append("<tr><td>" + data[i].user_name + "</td><td>" + data[i].address + "</td><td>" + data[i].email + "</td><td>" + data[i].mobileno + "</td><td><button onclick="update()"/></td></tr>");                  }              },              error: function () { alert('user not added'); }          });        });

you need pass event function string. dom handle it

$(document).ready(function () {         $.ajax({             url: '/api/userapi/',             type: 'get',             contenttype: "application/json;charset=utf-8",             datatype: "json",             success: function (data) {                  alert('user added successfudly');                  (var = 0; < data.length; i++) {                          $("#absa").append("<tr><td>" + data[i].user_name + "</td><td>" + data[i].address + "</td><td>" + data[i].email + "</td><td>" + data[i].mobileno + "</td><td><button onclick='update()'/></td></tr>");                 }             },             error: function () { alert('user not added'); }         });      }); 

updated

<button onclick='update()'/> 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -