Amit Dhamu

Software Engineer

Find a HTML Element With Text

Say you have some HTML markup with the following and want to retrieve the Find Me text, find will let us do this.

<div class="container">
  <span> </span>
  <span></span>
  <span></span>
  <span> Find Me</span>
  <span> </span>
</div>
Array.from(document.querySelectorAll('.container span'))
     .find(f => f.textContent.trim() !== '')
     .textContent.trim()

 html / querySelectorAll / find

Create A Folder For Each FileGet domain without subdomain

Show Comments

Made with by Amit Dhamu.
© MMXXI. All rights reserved.