Hello.

Below is the code that forms the table - dataTables in which there is a quick search, sorting the columns by name and there is a button by pressing, which is added to the line above and filled with such information

1.1 1.2 1.3

<script src="js/jquery.dataTables.min.js" type="text/javascript"></script> <script src="js/dataTables.bootstrap.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/jquery.dataTables.min.css"> <link rel="stylesheet" href="css/dataTables.bootstrap.min.css"> <script type="text/javascript"> $(document).ready(function() { var dataSet = [ [ "Tiger", "Nixon", "user1"], [ "Garrett", "Winters", "user2", ] ]; var t = $('#example').DataTable( { data: dataSet, columns: [ { title: "Ѐамилия" }, { title: "Имя" }, { title: "ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ" } ] } ); var counter = 1; $('#addRow').on( 'click', function () { t.row.add( [ counter +'.1', counter +'.2', counter +'.3' ] ).draw( false ); counter++; } ); // Automatically add a first row of data $('#addRow').click(); } ); </script> <div class="container"> <button id="addRow" class="btn btn-success"><i class="glyphicon glyphicon-ok-sign" ></i> Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ строку</button> <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Ѐамилия</th> <th>Имя</th> <th>ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ</th> </tr> </thead> <tfoot> <tr> <th>Ѐамилия</th> <th>Имя</th> <th>ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ</th> </tr> </tfoot> </table> </div> 

 <script src="js/jquery.dataTables.min.js" type="text/javascript"></script> <script src="js/dataTables.bootstrap.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/jquery.dataTables.min.css"> <link rel="stylesheet" href="css/dataTables.bootstrap.min.css"> <script type="text/javascript"> $(document).ready(function() { var dataSet = [ [ "Tiger", "Nixon", "user1"], [ "Garrett", "Winters", "user2", ] ]; var t = $('#example').DataTable( { data: dataSet, columns: [ { title: "Ѐамилия" }, { title: "Имя" }, { title: "ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ" } ] } ); var counter = 1; $('#addRow').on( 'click', function () { t.row.add( [ counter +'.1', counter +'.2', counter +'.3' ] ).draw( false ); counter++; } ); // Automatically add a first row of data $('#addRow').click(); } ); </script> <div class="container"> <button id="addRow" class="btn btn-success"><i class="glyphicon glyphicon-ok-sign" ></i> Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ строку</button> <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Ѐамилия</th> <th>Имя</th> <th>ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ</th> </tr> </thead> <tfoot> <tr> <th>Ѐамилия</th> <th>Имя</th> <th>ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ</th> </tr> </tfoot> </table> </div> 

The problem is that even at the initial launch of the form, an event of adding a row is immediately triggered.

Tell me where the error is.

Closed due to the fact that off-topic participants are VenZell , zRrr , Denis , aleksandr barakin , Bald Jul 22, '16 at 3:36 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - VenZell, zRrr, Denis, aleksandr barakin, Bald
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    problem solved

     // Automatically add a first row of data // $('#addRow').click();