我一直在學校網站上工作,出于某種原因,當我嘗試更改控制臺輸出的源鏈接時Uncaught TypeError: Cannot set property 'href' of null at pierre (pierre.html:49) at HTMLButtonElement.onclick (pierre.html:60)我試圖通過更改 ID 來解決此問題,但它也不起作用,即使將“link1”行復制并粘貼到“link2”行上也不起作用。<!DOCTYPE html><html> <head> <meta charset="utf-8"> <meta content="pierre, omidyar, bourne"> <title id="title">Pierre Omidyar</title> </head><script> var x = 0; function pierre() { if (x == 0) { x = 1 document.getElementById('title').innerHTML='Pierre\xa0Bourne'; document.getElementById('heading').innerHTML='Pierre\xa0Bourne'; document.getElementById('tag').play(); document.getElementById('image1').src='https://cdn3.pitchfork.com/longform/699/Pierre1.jpg'; document.getElementById('cite1').innerHTML = "Sheldon Pearce, Pitchfork.com, 2019"; document.getElementById('para1').innerHTML = "Jordan Timothy Jenks, known professionally as Pi\'erre Bourne, is a Belizean-American record producer, rapper, songwriter, and audio engineer. He is known for producing the singles \"Magnolia\" by Playboi Carti, and \"Gummo\" by 6ix9ine, with the two peaking at number 29 and 12 on the US Billboard Hot 100 respectively."; document.getElementById('link1').href = "https://en.wikipedia.org/wiki/Pierre_Bourne"; document.getElementById('image2').src='https://cdn3.pitchfork.com/longform/699/Pierre4.jpg'; document.getElementById('para2').innerHTML = "Songs Pierre Bourne has produced"; document.getElementById('l1o1').innerHTML = "Magnolia"; document.getElementById('l1o2').innerHTML = "wokeuplikethis*"; document.getElementById('l1o3').innerHTML = "Pissy Pamper"; document.getElementById('l1o4').innerHTML = "Pain 1993"; document.getElementById('link2').href = "https://en.wikipedia.org/wiki/Pierre_Bourne";
為什么控制臺說不能設置null的屬性
慕姐4208626
2023-03-24 15:09:46