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 td
s. 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];
精彩评论