I wish to link different sites to the pictures. All I did is link the pictures to the same link. So I want to link each pictures to the different website.
我希望将不同的网站链接到图片。我所做的就是将图片链接到同一个链接。所以我想将每张图片链接到不同的网站。
<!DOCTYPE html>
<html>
<head>
<style>
#rectangle{
width:2500px;
position:absolute;
margin-left:200px;
}
</style>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function () {
$('.crimson').css('width', 250);
setInterval(function () {
$('.crimson').first().appendTo('#rectangle a' );
}, 2000);
});
</script>
</head>
<body>
<div id="rectangle">
<a href="html/Main.html">
<img class="crimson"src="../pictures/CS151120.jpg"/>
<img class="crimson" src="../pictures/CS151204.jpg" />
<img class="crimson" src="../pictures/CS151218.jpg" />
<img class="crimson" src="../pictures/CS151231.jpg" /></a>
</div>
</body>
</html>
So adding 'a' behind the appendTo rectangle is the best thing I can do.
因此,在appendTo矩形后添加'a'是我能做的最好的事情。
2 个解决方案
#1
0
Try wrapping each picture in to individual <a></a>
<a href="destination1"><img class="crimson"src="../pictures/CS151120.jpg"/></a> <a href="destination2"><img class="crimson" src="../pictures/CS151204.jpg" /></a> <a href="destination3"><img class="crimson" src="../pictures/CS151218.jpg" /></a> <a href="destination4"><img class="crimson" src="../pictures/CS151231.jpg" /></a>
#2
0
$(document).ready(function () {
$('.crimson').css('width', 250);
setInterval(function () {
// $('.crimson').first().appendTo('#rectangle a');
}, 2000);
$('#rectangle .crimson').each(function () {
link = "html/Main" + $(this).index() + ".html";
$(this).wrap("<a href='"+link+"'/>");
});
});
#1
0
Try wrapping each picture in to individual <a></a>
<a href="destination1"><img class="crimson"src="../pictures/CS151120.jpg"/></a> <a href="destination2"><img class="crimson" src="../pictures/CS151204.jpg" /></a> <a href="destination3"><img class="crimson" src="../pictures/CS151218.jpg" /></a> <a href="destination4"><img class="crimson" src="../pictures/CS151231.jpg" /></a>
#2
0
$(document).ready(function () {
$('.crimson').css('width', 250);
setInterval(function () {
// $('.crimson').first().appendTo('#rectangle a');
}, 2000);
$('#rectangle .crimson').each(function () {
link = "html/Main" + $(this).index() + ".html";
$(this).wrap("<a href='"+link+"'/>");
});
});