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
我希望这个简单的代码片段能够帮助您。
我希望这个简单的代码片段能够帮助您。