0
<body>
   <section>
      <p id="status"></p>
      <button>Send</button>
   </section>
</body>

Above is the HTML code,and I add an event to the button with the above Javascript code:

<script type='text/javascript'>
    var status = document.querySelector('#status');
    var sendBtn = document.querySelector('button');
    sendBtn.addEventListener('click',function(){
        status.innerHTML='online'
    });
</script>

When I click the button it doesn't work (I use Google Chrome 27), but IE,Firefox and Ppera work well. I think the variable status is not defined in the anonymous function. Can anyone tell me why?

dda
  • 6,030
  • 2
  • 25
  • 34
teemo
  • 75
  • 5

1 Answers1

1

Thanks,Finally I solve the problem. status is a reserved word in the chrome.

teemo
  • 75
  • 5