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

时间:2018-07-07 06:12:25

标签: javascript html5

使用此代码时 无法检索图像和视频。

我的代码是

<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>

1 个答案:

答案 0 :(得分:0)

id选择器需要带有#号。因此您可以尝试使用document.getElementById(“#images”)类似的

相关问题