📅  最后修改于: 2022-03-11 15:03:39.278000             🧑  作者: Mango
function myFunction() {
var y = document.getElementById("txt1").value;
var z = document.getElementById("txt2").value;
var x = parseInt(y) + parseInt(z);
// document.getElementById("demo").innerHTML = x;
document.getElementById("txt3").value= x;
var elem = document.querySelector('#txt3');
if(x < 50)
// Set color to purple
elem.style.color = 'red';
else
// Set color to purple
elem.style.color = 'green';
}