mortido,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
div > div{
background-color: #FF0000;
color: #FFFFFF;
display: inline-block;
}
</style>
</head>
<body>
<div id="0">Первая @ строка</div>
<div id="1">Вторая @ строка</div>
<div id="2">@ Третья строка @</div>
<script>
const array = ['<div>1</div>', '<div>2</div>','<div>','</div>'];
let i = 0;
document.querySelectorAll('[id="0"], [id="1"], [id="2"]').forEach(div => {
let {textContent} = div;
let innerHTML = textContent.replace(/@/g, _=> array[i++]||`@`);
Object.assign(div, {innerHTML})
})
</script>
</body>
</html>