javascript - Append a new row to a table using jQuery -


this question has answer here:

i'm using following code trying append new row jquery it's not working.

$('#search-results > tbody').append('<tr><td data-th="name">test</td><td data-th="email">test@test.com</td><td data-th="phone number">07777777777</td><td data-th="car reg.">ocf83or</td><td data-th="time">1pm</td></tr>'); 

my table setup so:

<table class="view-bookings-table mobile-optimised hidden" id="search-results">     <thead>         <tr>             <th scope="col">name</th>             <th scope="col">email</th>             <th scope="col">phone number</th>             <th scope="col">car reg.</th>             <th scope="col">time</th>         </tr>     </thead>     <tbody></tbody> </table> 

edit

my full code actually:

$('#search').submit(function(event) {     event.preventdefault();     $('#search-results > tbody').append('<tr><td data-th="name">test</td><td data-th="email">test@test.com</td><td data-th="phone number">07777777777</td><td data-th="car reg.">ocf83or</td><td data-th="time">1pm</td></tr>'); }); 

your code fine , works every possible version of jquery.

demo

you may have jquery error somewhere else on page or not loading it.

class='hidden'  

doing? maybe it's css issue?


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -