Below is the example for how to bind click event on dynamically created elements.
If you having trouble with such issues, then use the below code.
Here is the HTML
<a href="#" class="button">Button</a>
<div class="list-cover">
<table>
<thead>
<tr>
<th>first</th>
<th>Second</th>
<th>last</th>
</tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>Second</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>Second</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>Second</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>Second</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>Second</td>
<td>last</td>
</tr>
</tbody>
</table>
</div>
Here is the CSS
table{
width:100%;
}
table th{
text-align:left;
}
.list-cover{
width:500px;
margin:auto;
}
Here is the Code(JQuery)
$(function(){
$('.button').click(function(){
var html = $('.list-cover').html();
$(html).appendTo('.list-cover');
$(html).prependTo('.list-cover');
});
});
0 Comment(s)