javascript中如何通过td的id得到其背景色

2025-03-11 03:05:30
推荐回答(5个)
回答1:

var color = document.getElementById("id").style.backgroundColor;
此时color就是你要得到的背景色...

回答2:

var s = document.getElementById("要获取td的id").style.background;
s就是得到的颜色

回答3:

document.getElementById('id').style.backgroundColor="green";直接用对象访问样式的属性。

回答4:

document.getElementById("td的id").style.backgroundColor
应该能取得

回答5:

呵呵,楼上的回答都是对的,你看着用吧