开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜