.width() giving error $(…)[0].width is not a function?

前端 未结 4 951
生来不讨喜
生来不讨喜 2021-01-19 05:01

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,

4条回答
  •  一向
    一向 (楼主)
    2021-01-19 05:45

    Use eq(0) instead of [0] to preserve the jQuery object that has the width() function.

提交回复
热议问题