$(function(){
//表格title属性赋值
var tr = $(".tab-txt tr").eq(0);
if ('操作' == tr.children('td:last-child').text()) {
var cellIndex = tr.children('td').size() - 1;
} else {
var cellIndex = tr.children('td').size();
}
$(".tab-txt tr td").each(function() {
if (this.parentNode.rowIndex != 0 && this.cellIndex != cellIndex) {
$(this).attr("title", $(this).text());
}
});
})
代码放到jsp页面可以正常运行,防到js里就不行了
tr.children('td:last-child').text()取得一个空值,
为什么不行呢
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!
针对:tr.children('td:last-child').text()取得一个空值
children()是jq的方法,必须遵循他的规范,你可以在定义的时候var $tr = $(".tab-txt tr").eq(0);
你js文件放到jquery下面没有,存为js文件和直接放jsp页面没有什么区别,注意导入顺序
还有dom对象的生成循序