Hello,
To search for string in attribute, you can use the Attribute = Value selector.
Documentation: https://www.w3schools.com/cssref/sel_attribute_value.asp
Example:
var texto1 = $('[class*="teste1"]').text();
var texto2 = $('[class*="teste5"]').text();
var texto3 = $('[class*="teste9"]').text();
$('#seletor-1').html(texto1);
$('#seletor-2').html(texto2);
$('#seletor-3').html(texto3);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="teste1 teste2 teste3">Lorem ipsum sit dolor ommet 1</p>
<p class="teste4 teste5 teste6">Lorem ipsum sit dolor ommet 2</p>
<p class="teste7 teste8 teste9">Lorem ipsum sit dolor ommet 3</p>
<hr>
<p id="seletor-1"></p>
<p id="seletor-2"></p>
<p id="seletor-3"></p>
In the case of this example, we used [class*="WORD"], where "class" is the attribute of the tag (could be any other attribute), "*=" is an operator indicating "contain" and "WORD" is the string to be searched for.
What exactly do you mean by searching for words? jQuery uses CSS selectors, so you can use any CSS selector rule to do your search. CSS selector reference: https://www.w3schools.com/cssref/css_selectors.asp
– Diego Marques
Man, I don’t know how to express myself very well in this situation, but I really need the word selection. In this case, if any, put words in place of '.Classe1'. classe2' I don’t really know if this is possible by simply typing the words didn’t work out, but I’m searching otherwise.
– user87941
Try to describe better what you want to do, who knows the solution may be different from what you are trying.
– Wendel Rodrigues
I have an html that will look for these classes, and appear after them, but I wanted to do it by words I know my explanation is confusing, it was really personal
– user87941