id_full = document.querySelector("div:contains('Регион')").getAttribute('id');
Uncaught DOMException: Document.querySelector: 'div:contains('Регион')' is not a valid selector
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> <style type="text/css"> .red { background-color: #FF0000; } </style> </head> <body> <p>1</p> <div class="advclass">Регион</div> <p class="advclass">1</p> <script> function containsAll(sel, str) { return [...document.querySelectorAll(sel)].filter(({ textContent }) => textContent.includes(str)) } let elem = containsAll('div', 'Регион')[0]; elem.classList.add('red') </script> </body> </html>