请问有人能写出这道题答案吗,js的

img

哈喽,代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .out{
      border:1px solid #ccc;
      width: 200px;
      margin:10px 0;
    }
  </style>
</head>
<body>
  <p id="showText">请为文字选择颜色和字号</p>
  <div class="out">
  选择颜色<br/>
  <label><input name="Color" type="radio" value="red" onclick="changeColor(this.value)"/>红色 </label> 
  <label><input name="Color" type="radio" value="green" onclick="changeColor(this.value)"/>绿色 </label> 
  <label><input name="Color" type="radio" value="blue" onclick="changeColor(this.value)"/>蓝色 </label> 
</div>

  <div class="out">
  选择字号<br/>
    <select name="" onchange="changeSize(this)"> 
      <option value="20px">20px</option> 
      <option value="22px">22px</option> 
      <option value="24px">24px</option> 
    </select> 
  </div>

  <script>
    function changeColor(color){
        document.getElementById("showText").style.color=color
    }
    function changeSize(selObj){
      document.getElementById("showText").style.fontSize=selObj.options[selObj.selectedIndex].value
    }
  </script>
</body>
</html>


<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <p id="text">4444</p>
  红色: <input type="radio" name="color" value="red" />
  绿色: <input type="radio" name="color" value="green" />
  蓝色: <input type="radio" name="color" value="blue" />

  <select name="size" id="size">
    <option value="20">20px</option>
    <option value="30">30px</option>
  </select>
</body>
<script>
  let color = document.getElementsByName("color");
  let size = document.getElementById("size");
  let h = document.getElementById("text");
  size.onchange = function (e) {
    let val = e.target.value;
    h.style.fontSize = val + "px"
  }
  let c;
  for (var i = 0; i < color.length; i++) {
    color[i].onchange = function (e) {
      h.style.color = e.target.value;
    }
  }
  console.log(color)
</script>

</html>