Table遍历行:
$(document).ready(function() {
$("#table a").each(function (){
this.onclick = function(){
var thisObj = this.parentNode.parentNode;
var a = $(thisObj).children();
var arr = new Array();
var laber = $("#xiugai label");
for(var i=0;i<a.length;i++){
arr[arr.length] = a.eq(i).text();
}
for(var i=0;i<laber.length;i++){
laber.eq(i).text(arr[i]);
}
$("#table").hide();
$("#xiugai").show(2000)
}
});
});
function fanhui(){
$("#table").show(2000);
$("#xiugai").hide(2000);
}
Table 遍历列:
$("table tr td:eq(5)").each(){ //循环table的第五列
alert($(this).html());
}
$("#attachmentTemp").each(function () {
var tr = this.childNodes;
for (var i = 0; i < tr.length; i++) {
if (i % 2 != 0) {
tr[i].className = 'alter';
}
else {
tr[i].className = 'alterNo';
}
}
});
ar table = document.getElementById('tblOne'),
rowLength = table.rows.length
for (var i = 0; i < rowLength; i += 1) {
var row = table.rows[i],
cellLength = row.cells.length
// your code goes here, looping over every row.
// cells are accessed as easy
for (var y = 0; y < cellLength; y += 1) {
var cell = row.cells[y]
//do something with every cell here
}
}
$('#tblOne > tbody > tr').each(function() {...code...});
$("#tab tr td:nth-child(1)").each
(
function()
{
alert($(this).text());
}
);
$("table[id^=ctl] input[type=radio]").each(function(i) {
arr.push(this.checked);
});
$("table[id^=ctl] input[type=radio]") 或者
$("table[id^=ctl]").find("input[type=radio]"
先获得你拖动的那里列的tr然后jquery 里面有个相当好用的方法 :nth-child
你自己可以去琢磨琢磨:nth-child 返回值:Array<Element(s)>概述匹配其父元素下的第N个子或奇偶元素':eq(index)' 只匹配一个元素,而这个将为每一个父元素匹配子元素。:nth-child从1开始的,而:eq()是从0算起的!可以使用:nth-child(even):nth-child(odd):nth-child(3n):nth-child(2):nth-child(3n+1):nth-child(3n+2)参数indexNumber要匹配元素的序号,从1开始示例描述:在每个 ul 查找第 2 个liHTML 代码:<ul> <li>John</li> <li>Karl</li> <li>Brandon</li></ul><ul> <li>Glen</li> <li>Tane</li> <li>Ralph</li></ul>jQuery 代码:$("ul li:nth-child(2)")结果:[ <li>Karl</li>, <li>Tane</li> ]