1. 程式人生 > >利用純js實現判斷變色功能

利用純js實現判斷變色功能

table=document.getElementsByTagName('table');
for(i=0; i<table[0].rows.length; i++){
	if(table[0].rows[i].cells[3].textContent > '2018-12-20'){
		table[0].rows[i].cells[3].style.backgroundColor="red";
	}else{
		table[0].rows[i].cells[3].style.backgroundColor="green";
	}
}