js 动态加载td :$('#thead').after("<tr><td id='code"+nCode+"' style='cursor:pointer;color:black;' οnclick='crawlTempleTest("+nCode+","+tplGrade+");'>"+nCode+"</td></tr>");
获取tdstyle:
var templetList = $('#code'+nCode);
// $('#code'+nCode).style.color="green";
if(templetList.style.color=="red"){
templetList.style.color="green";
}else{
templetList.style.color="red";
}
报错:Cannot read property 'color' of undefined
解决:jQuery对象没有style属性,样式通过css设置
var templetList = $('#code'+nCode);
var color = templetList.css("color");
if('rgb(0, 0, 0)'==color){
templetList.css("color","RoyalBlue");
}else{
templetList.css("color","black");
}