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

217
Visualizações
Get attribute of child element

If I have the following markup:

<p class="header hours">
    <a href="javascript:void(0)" class="sort" sortcat="hours">
        Hours&nbsp;<span class="imgholder" sortcat="hours">&nbsp;</span>
    </a>
</p>

How can I target the <span> tag within the anchor tag? There are five other similar <p> tag entries, each with a different value for sortcat=

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

$(".sort").click(function(){
  var cat =  $(this).children("span").attr("sortcat");
  //do something with the sortcat
});
over 4 years ago · Santiago Trujillo Relatório

0

$("a span[sortcat]").attr('sortcat')

That'll give you the first element's sortcat value. To get all of them, do this:

$("a span[sortcat]").map(function(){ return $(this).attr('sortcat') })

See this working demo: http://jsfiddle.net/BwgDW/

over 4 years ago · Santiago Trujillo Relatório

0

$('.sort span')

Did I misunderstand?

over 4 years ago · Santiago Trujillo 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