jquery - Multiple tables don't work -


this question has answer here:

i have button:

<td class="rigaconto">   <a class="btn btn-default separa_conto" data-conto="2" data-toggle="tooltip" data-original-title="newaccount"><i class="fa fa-sitemap"></i></a> </td> 

and jquery code:

$(function(){   $(".separa_conto").click(function() {     var conto = $(this).data('conto');     var nuovoconto = conto + 1;     alert(conto);     $('#showaddeb_conto_'+ conto).removeclass('hidden').show('slow');     $('#showaddeb_conto_'+ conto).append('<tr><td></td><td>sogg</td><td>1000</td><td></td></tr>');     $('.rigaconto').append('<a class="btn btn-default separa_conto" data-conto="'+ nuovoconto +'" data-toggle="tooltip" data-original-title="separa conto"><i class="fa fa-sitemap"></i></a>');      var table = $('<table></table>').attr('id','showaddeb_conto_'+ nuovoconto).addclass('table table-hover table-bordered hidden');     var row = $('<tr><th></th><th>further account</th><th></th><th></th></tr>');     table.append(row);      $('#tabelle_conti').append(table);    }); }); 

but if click twice class "newaccount" doesn't appear second table. mistake?

it looks trying click button added after event binding. can instead attach event parent element (like <body>), fire when triggered buttons special class. buttons added later trigger event. change binding so:

$("body").on("click", ".separa_conto",function()      {         ...      }) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo