繁体   English   中英

如何在html5gallery href和src中动态添加路径?

[英]How to add path in html5gallery href and src dynamically?

使用此代码时,不会检索图像和视频。

我的代码是

<script language="JavaScript">
    function onSlideChange(data) {
                document.getElementById("images").src = "http://localhost:8080/MyApp/4gB7a.jpg";
        document.getElementById("vide").href = "http://localhost:8080/MyApp/4gB7a.jpg";
        try {
            console.log(data);
        } catch (error) {
        }
    }
</script>
<div class="html5gallery" data-width="480" data-height="270"
    data-onchange="onSlideChange" style="display: none;">
    <a href="" id="vide"><img src="" id="images"></a> <a
        href="http://localhost:8080/MyApp/2.jpg"><img
        src="http://localhost:8080/MyApp/2.jpg" alt="Island"></a>

</div>

id选择器必须带有#号。 因此您可以尝试使用document.getElementById(“#images”)之类的方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM