📌  相关文章
📜  如何在 jquery 中将变量转换为字符串 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:39.278000             🧑  作者: Mango

代码示例3
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';
  }