javascript - Append a new row to a table using jQuery -
this question has answer here:
- add table row in jquery 30 answers
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.
you may have jquery error somewhere else on page or not loading it.
class='hidden'
doing? maybe it's css issue?
Comments
Post a Comment