Javascript error: Cannot read property 'parentNode' of null

前端 未结 2 1739
广开言路
广开言路 2021-02-19 07:27

The javascript I am using:

javascript: c = \'{unit}, ({coords}) {player} |{distance}| {return}\';
p = [\'Scout\', \'LC\', \'HC\', \'Axe\', \'Sword\', \'Ram\', \         


        
2条回答
  •  深忆病人
    2021-02-19 08:04

    There are two possibilities:

    1. editInput is a typo, and the actual id of that element is different (ids are case-sensitive).
    2. You are executing this code while the DOM is not ready. To prevent this, execute the code just before the closing tag, or wrap it in an event handler for the load event of window or the DOMContentLoaded event of document.

    EDITED How to wrap your code:

    window.onload = function() {
        //your code here
    };
    

提交回复
热议问题