Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
how to find specefique html element by keyword?

im having problems on how to find a specifique html element when having a keyword:

...

<div class="col-sm-6 col-md-6 col-lg-4">
    <div class="ct-itemProducts ct-u-marginBottom20" >
                                    <div class="ct-main-content">
                                    
                                        <div class="ct-main-text" >
                                            
                                            <div class="ct-product--tilte">
                                                COMPUTIME
                                            </div>
                                            ...
                                        

my keyword is COMPUTIME aand i whant to detect className of this div

<div class="col-sm-6 col-md-6 col-lg-4">
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You can try this with JavaScript:

for (const a of document.querySelectorAll(".ct-product--tilte")) {
  if (a.textContent.includes("COMPUTIME")) {
  console.log(a.textContent)
  }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

EDIT : As i understand, you want to get element class by searching on the TEXT in your div, then you can try something like this :

var allElement = document.querySelectorAll('*');
var myElement = null;

var valueToSearch = "COMPUTIME"; 

allElement.forEach(el => {
  if(el.innerHTML.trim() === valueToSearch) {
    myElement = el;
  }
})

console.log(myElement) // My element HTML
console.log(myElement.className) // My Class 
console.log(myElement.id) // My id

var parentSearching = true;

while(parentSearching) {
  myElement = myElement.parentElement;
  if (myElement.className.includes('col')) {
    parentSearching = true;
    break;
  }
}

console.log(myElement.className); // col-sm-6 col-md-6 col-lg-4
<div class="col-sm-6 col-md-6 col-lg-4">
  <div class="ct-itemProducts ct-u-marginBottom20" >
    <div class="ct-main-content">
      <div class="ct-main-text" >
        <div class="ct-product--tilte">
          COMPUTIME
        </div>        
      </div>
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

I did not understand your question but if you want to detect/access any class in CSS then use "." before the class name like ".col-sm-6 col-md-6 col-lg-4" and for id use "#" like "#col-sm-6 col-md-6 col-lg-4"

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda