我正在开发一个图像共享网站,现在我正在努力在页面上呈现用户相册.每张专辑至少包含图像,我想在每个框中将所有专辑显示为具有四个缩略图(专辑中的前四个图像)的框.
图像文件名存储在每个框中隐藏输入字段的值中,我想要做的是从每个相册框中获取所有文件名并将其显示为缩略图.
我需要帮助的部分是我将如何从每个相册框中逐个获取文件名.下面的代码由于显而易见的原因不起作用,但如何重写以使其有效?所有输入字段都具有相同的类名.
提前致谢!
if ($('.hiddenAlbumNames').length > 0){
var images = $(this).val();
// the rest of the code (creating images and putting them in the album boxes)
}
Run Code Online (Sandbox Code Playgroud)
你必须循环$('.hiddenAlbumNames')jQuery集合以获得所有输入的值
$('.hiddenAlbumNames').each(function() {
console.log( $(this).val() );
/* rest of the code for each name retrieved */
})
Run Code Online (Sandbox Code Playgroud)