我想制作一个函数,该函数可以更改div标签中存在的段落的字体大小和文本对齐属性,该标签在按下按钮时执行。

function acknowledge()
{
  document.getElementById('centretext').innerHTML = "";
  document.getElementById('button1').style.display = "none";
  document.getElementById('centretext').style.font-size = "99%";
  document.getElementById('centretext').style.text-align = "left";
}


它的原始属性是:

#centretext
{
  font-size: 200%;
  font-family: Merriweather;
  text-align: center;
  font-weight:bolder;
}


然而,当单击按钮时,什么也没有发生。如果我删除了函数的最后两行(即更改属性的那一行),那么前两行就可以执行了。我究竟做错了什么?
编辑:div:

<div id = "centre">
      <p id="centretext">
        You are a cell.
        <br>
        It's the survival of the fittest.
        <br>
        <br>
        To survive, you must divide, grow and evolve.
      </p>

      <p id="centretext2">
      </p>

      <button class ="buttonformat" id="button1" type="button" onclick="acknowledge()"> OK </button>
      </div>

最佳答案

    document.getElementById('centretext').style.fontSize = "99%";
    document.getElementById('centretext').style.textAlign = "left";

10-08 00:21