I am having trouble trying to remove the first column from every row. I have a felling it is my understanding of jquery.
I've tried the following.
$("table:eq(2) tr td:first").remove() // this only removed the first cell
$("table:eq(2) tr td:first").each.remove() // didn't notice a difference
Any ideas of what I'm doing wrong?
Try using td:first-child instead of td:first
See this page for more: http://api.jquery.com/first-child-selector/
P.S. A couple of suggestions for your jQuery selector:
Use a table id or class instead of index identification because if you move your table in the DOM, your selector will break
I'm pretty sure you don't need the "tr"
So:
$("#myTable td:first-child").remove()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With