如果我有一个用拇指写图片的功能——我如何获得图片编号以用于点击

If I have a function that write pictures in a thumb - How can I get the picture number for use to onclick

本文关键字:何获得 用于 编号 有一个 如果 功能      更新时间:2023-09-26

如果我有一个用拇指写图片的函数。如何获取图片编号以用于onclick显示BigPic?仅使用js和html

<script>
var MinPixNr=100;
var MaxPixNr=115;
var title='Sofie';
var Nr=100;
//make the thumb album
  for (MinPixNr=100;MinPixNr<=115;MinPixNr++) {
document.write('<img onclick="ShowBigPic()" src="images/thumb/'+title+''+MinPixNr+'.jpg.">');
}
function ShowBigPic()
{
element=document.getElementById('BigPic');   
element.src="images/large/'+title+'"+help+".jpg";//help: i need the pic-number from the thumb
}
</script>

<body>
<script>
document.write('<br><hr><br>');
document.write('<IMG src="images/large/'+title+''+Nr+'.jpg" id="BigPic" >');
</script>

</body>

用函数调用发送图像的名称:

document.write('<img onclick="ShowBigPic('+MinPixNr+')"
function ShowBigPic(MinPixNr)

根据评论编辑。