开发者

How can I find the last visible <td> in a table?

开发者 https://www.devze.com 2023-03-12 05:21 出处:网络
I am using a table with one row and several <td>s insid开发者_如何学编程e it and am using hide/show on tds. Every td has a unique id.

I am using a table with one row and several <td>s insid开发者_如何学编程e it and am using hide/show on tds. Every td has a unique id.

Is there any way to recognize the last visible td from that table?


Yes, that's pretty trivial with jQuery

$('td:visible:last')

See this fiddle


In plain Javascript, I guess it should be something like this:

var els = document.getElementsByTagname('td');
for (var i = 0 ; i < els.length ; i++)
  if (els[i].style && els[i].style.display != 'none')
    last = els[i];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号