Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Tabla de datos del cuadro de búsqueda fuera de la tabla

Estoy tratando de crear tablas de datos de cuadro de búsqueda fuera de la tabla, estoy usando la versión 1.12.1 de tablas de datos, uso la referencia del sitio web y no funcionará, el cuadro de búsqueda no funciona.

El resultado:

ingrese la descripción de la imagen aquí

 oTable = $('#example').dataTable(); $('#myInputTextField').keyup(function() { oTable.search($(this).val()).draw(); })
 <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script> <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css"> <input type="text" id="myInputTextField"> <table id="example" class="display" style="width:100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start date</th> <th>Salary</th> </tr> </thead> <tbody> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011-04-25</td> <td>$320,800</td> </tr> <tr> <td>Foo bar</td> <td>Engineer</td> <td>Glasgow</td> <td>45</td> <td>2012-05-26</td> <td>$100,800</td> </tr> </tbody> </table>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para obtener una referencia a la instancia de la tabla de datos, debe usar DataTable() , no dataTable() . Este último proporciona un objeto jQuery.

También sugeriría usar el evento de input para el cuadro de búsqueda, ya que permite a los usuarios ingresar texto de cualquier manera posible, no solo usando el teclado.

 let oTable = $('#example').DataTable(); $('#myInputTextField').on('input', function() { oTable.search($(this).val()).draw(); })
 <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script> <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css"> <input type="text" id="myInputTextField"> <table id="example" class="display" style="width:100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start date</th> <th>Salary</th> </tr> </thead> <tbody> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011-04-25</td> <td>$320,800</td> </tr> <tr> <td>Foo bar</td> <td>Engineer</td> <td>Glasgow</td> <td>45</td> <td>2012-05-26</td> <td>$100,800</td> </tr> </tbody> </table>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!