如一个表格
<table>
<tr>
<TD abbr=Version align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 50px">V1.0</DIV></TD>
<TD abbr=FileType align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">.txt</DIV></TD>
<TD abbr=FileSize align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">2,304.05</DIV></TD>
</tr>
</table>如何获取一行中每个td的abbr,最终获取到所有的abbr.
如
var arr="Version,FileType,FileSize";
<table>
<tr>
<TD abbr=Version align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 50px">V1.0</DIV></TD>
<TD abbr=FileType align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">.txt</DIV></TD>
<TD abbr=FileSize align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">2,304.05</DIV></TD>
</tr>
</table>如何获取一行中每个td的abbr,最终获取到所有的abbr.
如
var arr="Version,FileType,FileSize";
$('td').each(function(){
arr.push( $(this).attr('abbr') )
})
alert(arr)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://www.liuxiaofan.com/demo/js/jquery-1.6.4.min.js" type="text/javascript"></script></head><body>
<table>
<tr>
<TD abbr=Version align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 50px">V1.0</DIV></TD>
<TD abbr=FileType align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">.txt</DIV></TD>
<TD abbr=FileSize align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">2,304.05</DIV></TD>
</tr>
</table>
<script>
var abbr = '';
$('table td').each(function(){
abbr += $(this).attr('abbr') + ',';
})
alert(abbr);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://www.liuxiaofan.com/demo/js/jquery-1.6.4.min.js" type="text/javascript"></script></head><body>
<table>
<tr>
<TD abbr=Version align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 50px">V1.0</DIV></TD>
<TD abbr=FileType align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">.txt</DIV></TD>
<TD abbr=FileSize align=left>
<DIV style="TEXT-ALIGN: left; WIDTH: 60px">2,304.05</DIV></TD>
</tr>
</table>
<script>
var tds = [],abbr = [];
$('table td').each(function(){
tds.push($(this));
abbr.push($(this).attr('abbr'));
})
alert(tds);
alert(abbr);
</script>
</body>
</html>
$('td').each(function(){
alert($(this).attr('abbr'));
});
});