javascript - 通过 DIV 数据打开图像

标签 javascript jquery html css

我再次请求你的帮助,我有一个 ftp,其中有一些我想使用的音乐封面 http://inlivefm.6te.net/capas/ .

我还有一个 javascript 可以给我封面链接的数据:他现在要提供的链接 http://inlivefm.6te.net/capas/I需要你的爱.jpg 最后一首歌播放

我使用 JavaScript 提供封面

<head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            //  Defino my variable global
            var myObj = {}; 
            $.ajax({
                type: "GET",
                url: "/AirPlayHistory.xml",
                dataType: "xml",
                success: function(xml) {
                    $(xml).find('Song').each(function() {
                        //  Definimos el atributo tittle
                        myObj.tittle = $(this).attr('title');

                        $(this).find('Artist').each(function() {
                            //  Definimos el atributo artist
                            myObj.artist = $(this).attr('name');
                        });

                        $(this).find('Info').each(function() {
                            //  Definimos el atributo time
                            myObj.time = $(this).attr('StartTime');
                        });

                        $(this).find('Info').each(function() {
                            //  Definimos el atributo cover
                            myObj.cover = $(this).attr('JazlerID');
                        });

                        //  Por ultimo lo mostramos :)
                        $('.cancion').html("<p>http://inlivefm.6te.net/capas/" + myObj.tittle + ".jpg</p>");
                    });
                }
            });         
        });
    </script>
</head>
<body>
    <div class="cancion"></div>
</body>
</html>

知道div给我封面的链接,想打开提供数据的直通图

<img src="<div class="cancion"></div>
"/>

我想要的例子是这样的:

<img src="http://inlivefm.6te.net/capas/I NEED YOUR LOVE.jpg"/>

我正在尝试执行此操作,但由于图像无法打开我无法执行此操作,所以我来寻求您的帮助。

非常感谢!

最佳答案

我相信您想要一张图片,点击它会将您带到另一个资源;这样做:

<a href='resource.URL' ><img src='image.URL' other_attributes /></a>

点击 image.URL 将带您到 resource.URL

关于javascript - 通过 DIV 数据打开图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35831478/

相关文章:

javascript - 如何获取帖子总页数?

使用正则表达式进行 JavaScript 验证不起作用

javascript - 比较两个数组并计算事件

html - 如何确保此页面的样式正确流动?

javascript - 如何修复 Javascript 中的 'invalid ciphertext size' 错误? (aes)

javascript - 如何为 Canvas "drawing style"应用程序获取平滑的鼠标事件?

javascript - 跟随鼠标位置的平滑移动效果

javascript - Jquery 在滚动时触发动画一次

jQuery tablesorter - AJAX 调用后功能丢失

php - DIV 重叠图像而不是在 Chrome 中位于下方,在其他浏览器中看起来正确