【发布时间】:2021-11-27 22:04:03
【问题描述】:
我有这样的js代码:
lightGallery($("#web1")[0], {
selector: 'this',
mobileSettings: {
controls: false,
showCloseIcon: true,
download: false,
}
});
lightGallery($("#web2")[0], {
selector: 'this',
mobileSettings: {
controls: false,
showCloseIcon: true,
download: true,
}
});
lightGallery($("#web3")[0], {
selector: 'this',
mobileSettings: {
controls: false,
showCloseIcon: true,
download: true,
}
});
如何优化代码,让我不必每次都写一个新数字?
【问题讨论】:
-
欢迎来到 Stack Overflow。您可能希望使用
.each()来迭代每个项目。那么这就是正确选择器的问题。
标签: javascript jquery optimization lightgallery