I have a table, and I'm trying to find the width of each td in the table. I've tried all kinds of variations of: $("td")[0].width()
, but none of them work, getting an error of: "Uncaught TypeError: $(...)[0].width is not a function"
everytime.
I'm importing jQuery first, before my other JS files, (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js), and I'm using .width() not .width.
Any ideas?
$("td")[0]
is a DOM element not a jquery object. Simply wrap it as jquery $($("td")[0]).width()
You need to get width of each td
so you could use something like
$.each('td', function() {
var currentTDWidth = $(this).width(); // more code here
});
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