我想获取第一个的所有列值。例如在this Fiddle中当我访问 th 时,我想获取该列中的所有 td。
$(document).ready(function(){
$('.tableizer-table th').each(function(index,val){
$('.tableizer-table tr td').eq(index).each(function (index,value) {
console.log(value);
});
});
});
以上代码不起作用。
最佳答案
我假设当您悬停或访问列标题时,您希望将该列下的所有 td 元素写入控制台。
$(document).ready(function(){
$('.tableizer-table th').on('hover', function(){
var columnIndex = $(this).parent().index($(this));
$('.tableizer-table tbody tr').each(function() {
console.log($(this).children('td').eq(columnIndex).text());
});
});
});
关于javascript - 从html数据中获取Column数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38253141/