Hi I am trying to generate dynamically HTML tables using append(). The way I have written the code is if the user wants to enter the data in the localStorage it first checks if it is empty.If it is empty the code in if block gets executed.If not empty then the else block gets executed.All this code is in the getDetails() JavaScript function. I have given the dynamically generated table id as "myTable".
<table align="center" id="myTable">
</table>
<script>
function getdetails(){
if(localStorage.length == 0){
......
}
else{
do something ...
}
}
<script>
The issue is that I need to get the row number when I click the table row.For that I have created the following function.
$(window).load(function() {
$("#myTable tr").click(function(){
.....
});
});
The above code gets executed (window.load ) when the page refreshes or loads for th first time.But when I add another row in the HTML table( the code exceutes the else block since localStorage is not empty) and click any table row the code doesnt work. Could anyone please tell me on how to get the .click() to work every time.Thanks.