Uncaught TypeError: Cannot set property 'src' of null

后端 未结 1 420
鱼传尺愫
鱼传尺愫 2021-01-26 03:46

So while trying to work on this piece of code for school I keep running into this error. \"Uncaught TypeError: Cannot set property \'src\' of null\" Essentially what I\'m tryin

1条回答
  •  醉话见心
    2021-01-26 03:56

    Assuming that bigPic is in fact the ID of an img tag, you are going to want to do document.getElementById('bigPic') instead of using #bigPic.

    You are mixing the CSS selector that you'd use in jQuery or CSS (i.e., $('#bigPic')) with plain javascript. Using the getElementById function, you're already saying you're looking for something by the ID.

    0 讨论(0)
提交回复
热议问题