JSFiddle - React, Tailwind, and code Playground

by Sergei Sokolov

HTML

<input id="id_imgs" type="hidden" value="28838">
<input id="id_imgs" type="hidden" value="28839">
<input id="id_imgs" type="hidden" value="28840">
<output></output>

JavaScript

/**
 * для вопроса https://qna.habr.com/q/1027482
 * Как собрать в один массив JS несколько переменных из input с одинаковыми ID?
 */
document.querySelector('output').innerText = 
[...document.querySelectorAll('input')] // взять все input'ы
.filter((el) => el.id === 'id_imgs')   // оставить только с нужным id
.map((el) => el.value) // взять их значения
.join(', ');           // склеить в строку через разделитель