teemo
teemo

Reputation: 75

Weird Javascript Anonymous function under Google Chrome

<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?

Upvotes: 0

Views: 859

Answers (1)

teemo
teemo

Reputation: 75

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

Upvotes: 1

Related Questions