I need to generate 398 lines of html code. This is the first line:
我需要生成398行html代码。这是第一行:
{<img src="images/blackcelebratory/2014/001.jpg"/>}
then I need to increment the image name up to 398.jpg. So the name of the image on the last line would be:
然后我需要将图像名称增加到398.jpg。所以最后一行的图像名称是:
.../398.jpg
Is there a way, using a text editor, or Dreamweaver, or a bit of code, to automate generating these lines of code?
有没有办法,使用文本编辑器,Dreamweaver或一些代码,自动生成这些代码行?
3 个解决方案
#1
1
<?php
for ($x=0; $x<=398; $x++) {
echo "<img src="images/blackcelebratory/2014/". $x .".jpg"/>";
}
?>
#2
0
In jquery:
for(var i = 1; i<399; i++){
$("body").append("<img src='images/blackcelebratory/2014/"+i+".jpg' />");
}
#3
0
Try a loop: JSFIDDLE
尝试一个循环:JSFIDDLE
<script>
for(i = 1; i < 399; i++) {
var img = document.createElement('IMG');
var j = i.toString();
var num = [0, 0].slice(0, j.length < 4 ? 3 - j.length : 0).join('') + j;
img.src = "images/blackcelebratory/2014/" + num + ".jpg";
document.body.appendChild(img);
}
</script>
#1
1
<?php
for ($x=0; $x<=398; $x++) {
echo "<img src="images/blackcelebratory/2014/". $x .".jpg"/>";
}
?>
#2
0
In jquery:
for(var i = 1; i<399; i++){
$("body").append("<img src='images/blackcelebratory/2014/"+i+".jpg' />");
}
#3
0
Try a loop: JSFIDDLE
尝试一个循环:JSFIDDLE
<script>
for(i = 1; i < 399; i++) {
var img = document.createElement('IMG');
var j = i.toString();
var num = [0, 0].slice(0, j.length < 4 ? 3 - j.length : 0).join('') + j;
img.src = "images/blackcelebratory/2014/" + num + ".jpg";
document.body.appendChild(img);
}
</script>