84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
我有一張圖片,我想將其與網址連結。我用過javascript。 程式碼 after running the 程式碼 我想顯示此圖像,當我單擊它時,我想打開其他一些頁面,該頁面已通過 url 連結到此圖像。
我該怎麼做?
我試過了,但沒用。
程式碼(I took this from Stack Overflow)
function handleClick(){ const image = new Image () image.src = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" image.style.width="200px" image.style.height="200px" image.alt="Google logo" image.addEventListener("click", function() { window.location.href="https://www.google.com" }) const element = document.getElementById('image-container') if(element){ element.appendChild(image) } }
Image will show here Show me
我希望這個簡單的程式碼片段能夠幫助您。
我希望這個簡單的程式碼片段能夠幫助您。