How to detect element with DOM JavaScript?

If you can, use querySelector for this:

document.querySelector("div.red h2.title").style.backgroundColor = "#00c497";
<div>
  <h2>Don't Touch</h2>  
</div>
<div class="red">
  <h2>Don't Touch</h2>
  <h2 class="title">Change</h2>
</div>