function changeColor(obj)
{
var rowObject = getParentRow(obj);
var parentTable = document.getElementById("gvCategories");
if(color == '')
{
color = getRowColor();
}
if(obj.checked)
{
rowObject.style.backgroundColor = 'Yellow';
}
else
{
rowObject.style.backgroundColor = color;
color = '';
}
// private method
function getRowColor()
{
if(rowObject.style.backgroundColor == '') return parentTable.style.backgroundColor;
else return rowObject.style.backgroundColor;
}
}
// This method returns the parent row of the object
function getParentRow(obj)
{
do
{
if(isFireFox())
{
obj = obj.parentNode;
}
else {
obj = obj.parentElement;
}
}
while(obj.tagName != "TR")
return obj;
}
function isFireFox()
{
return navigator.appName == "Netscape";
}
转载于:https://blog.51cto.com/youxue/47614