javascript更改样式属性是否会破坏事件链?

时间:2016-10-05 11:09:40

标签: javascript html

我有以下html:

<span style="display:none" id="progressBar">HELLO</span>        
<span id="statusPremium">NULL</span>
<span id="statusLink">NULL</span>
<table>
  <tr>
    <td>
      <input type="text" value="12345" onchange="document.getElementById('statusPremium').innerHTML='ONCHANGE';document.getElementById('progressBar').style.display='block';"/>
    </td>
  </tr>
  <tr>
    <td>
      <a href="#" onclick="document.getElementById('statusLink').innerHTML='ONCLICK';">CLICK</a>
    </td>
  </tr>
</table>

输入输入项目然后进行编辑,然后点击链接。我希望两个文本即。 ONCHANGE ONCLICK出现。但是我只能看到ONCHANGE。 如果我删除:

document.getElementById('progressBar').style.display='block';

行为如我所料。但是如果那时我删除所有table,tr和td标签,那么只有ONCHANGE。 可以请一些人告诉我它为什么这样工作?

0 个答案:

没有答案