我的網站目前使用:你如何做一個for循環中的「href」鏈接?
for (var i = 1; i<25; i++){
$('#photos').append('<img src="Sections/Blondes/'+i+'.jpg">');
}
顯示圖像,但是當我做同樣的事情的 「href」:
$("#photos").append("href", "http://www.google.com/")
這裏是我的CSS 「#photos」:
#photos img {
width: 100% ;
height: auto;
}
@media only screen and (min-device-width: 1080px) {
#photos {
line-height: 0;
-webkit-column-count: 5;
-webkit-column-gap: 0px;
-moz-column-count: 5;
-moz-column-gap: 0px;
column-count: 5;
column-gap: 0px;
}
#photos img {
width: 100% ;
height: auto;
}
@media (max-width: 1200px) {
#photos {
-moz-column-count: 4;
-webkit-column-count: 4;
column-count: 4;
}
}
@media (max-width: 1000px) {
#photos {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
}
@media (max-width: 800px) {
#photos {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
}
@media (max-width: 400px) {
#photos {
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
}
}
我想爲每張圖片添加一個燈箱,並且要完成href鏈接。
燈箱我使用:
http://lokeshdhakar.com/projects/lightbox2/
如何才能做到這一點?
這不是html; html沒有循環。 –
'href'是一個錨點元素屬性..但我從來沒有見過它以你嘗試的方式使用。也許你正試圖設置一個屬性..你可以使用['.attr()'](http://api.jquery.com/attr/)函數來實現。 –
添加'href'與顯示圖像有什麼關係?你真的沒有描述你最終想要解決的問題。 – 2017-04-26 20:57:03