jquery - alert the value of an element on click of link Ajax -


how can alert value of element onclick of link here? simple alert not working inside , don't want use console.log()

var row = ''; $.each(result, function(index, element) {     row += '<tr>';     row += '<td>' + '<a href="" onclick="alert value here(alert(element.name)">' + "link" + '</a>' + '</td>'; }); 

save value in "data" element in link , later use value @ runtime when make click: example on fiddle

var row = ''; $.each(result, function(index, element) { row+='<tr>'; row += '<td>' + '<a data-name=' + element.name+ ' href=""      onclick="alert($(this).data(name));">' + "link" + '</a>' + '</td>'; }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -