JSFiddle - React, Tailwind, and code Playground

by lparcerisa

HTML

<div class="this_one">
  Need this !
</div>
<div id="some_three">
  Need this again !
</div>
<span id="two_this">
  Need again
</span>
<p class="NOT">
Not want this
</p>

JavaScript

var patterns = ["one","two","three"];

var text = "";
for(i in patterns) {
    text += $("[id*='"+patterns[i]+"']").text();
    text += $("[class*='"+patterns[i]+"']").text();
 }

alert(text);