javascript - 网站显示与目录中一样多的图像
问题描述
我想创建 HTML 网站,它将显示与目录中一样多的图像。可以有 5 个或 100 个。通过单击 NEXT/PREVIOUS 按钮,网站应显示目录中的单个图像。
$(document).ready(function () {
var images = [
"Icons/1.PNG",
"Icons/2.PNG",
"Icons/3.PNG"
];
var imageIndex = 0,
iLength = images.length - 1,
imageEl = $('#image'),
prevEl = $('#previous'),
nextEl = $('#hoger');
prevEl.on("click", function () {
imageIndex--;
imageEl.attr('src', images[imageIndex]);
nextEl.prop('disabled', false);
prevEl.prop('disabled', !imageIndex);
});
nextEl.on("click", function () {
imageIndex++;
imageEl.attr('src', images[imageIndex]);
nextEl.prop('disabled', imageIndex === iLength);
prevEl.prop('disabled', false);
});
prevEl.prop('disabled', true);
imageEl.attr(images[0]);
});
</script>
而不是列表中的图像var = images
,我需要读取图像计数。
解决方案
推荐阅读
- java - 如何使用 Apache Jena 的查询构建器向 SelectBuilder 添加 SERVICE 子句?
- javascript - 为什么“这个”会丢失?
- javascript - 如何根据复选框/框状态更改 URL 正文?
- google-bigquery - GROUP BY 使用 Ads Data Hub (BigQuery) 中的参数
- pine-script - 为什么当蜡烛颜色改变时这个脚本(pinescript)没有退出?
- php - Laravel 8:雄辩的查询似乎显示从数据库中检索到的数据
- sql - 从 INNER JOIN 向 MIN 和 MAX 语句添加其他列
- react-typescript - 如何在反应中为组件方法编写单元测试用例
- sql - 每次两个表值的总和,并在 SQL-Server 中找到总和结果的最小值
- java - 使用Java中的replace或extract方法从字符串中提取数字