javascript function to create a table
function createTable(){
var contTable="<table id='test'><tbody>"
$.ajax({
url:'getData.php',
jsonp:'callback',
data:datastring,
success:function(data){
if(data!=null){
for(var h=0;h<data.length;h++){>
contTable+="<tr id="+data[h]+ID+"><td>"+data[h].NAME+"</td></tr>"
}
}
contTable+="</tbody></table></tr></tbody></table></thead></table>";
document.getElementById("conttable").innerHTML=contTable;
},
error:function(){
}
});
}
$(document).ready(function(){
$('#test tr').click(function(){
selectedid=$(this).attr('id');
});
});
html
<div id="conttable"></div>
if I create a table in html for example
<table id="test">
<tr>
<td id="1">Name1</td>
</tr>
<tr>
<td id="2">Name2</td>
</tr>
<tr>
<td id="3">Name3</td>
</tr>
</table>
the click function works but not for a javascript table.What is wrong in this.Can anyone help me...