扫码关注官方订阅号
84669人学习
65727人学习
82984人学习
467778人学习
498837人学习
471966人学习
256484人学习
152542人学习
224170人学习
139536人学习
81804人学习
85022人学习
11944人学习
20001人学习
60816人学习
5487人学习
15007人学习
2150人学习
6980人学习
194925人学习
359900人学习
1142人学习
19058人学习
3206人学习
180550人学习
48569人学习
17603人学习
40936人学习
1049人学习
750人学习
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
我希望这个简单的代码片段能够帮助您。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2024 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号
精品班
技术支持
技术咨询
学习群
会员优惠
返回顶部
我希望这个简单的代码片段能够帮助您。