<li>1</li> <li>2</li> <li>3</li> <script> document.querySelectorAll('li').forEach(el=>el.textContent == 1 && el.classList.add('post')); </script>