JavaScript (JQuery) Search By Whole Word

Without jQuery :

var arr = document.querySelector('.someclass').textContent.split(',')

console.log(arr.filter(function (word) {
  return word.trim() === '345'
}))
<div class="someclass">3434 34, 345, 455, 432 423, 54563 4543, 23232, 232 323, 343 43, random numbers and letters with spaces</div>

Leave a Comment