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

187
Visualizações
What is $(.some-class:#some-hash) in jQuery?

I'm studying this article, the details of which are irrelevant to this question, which is about jQuery syntax.

In the example at the link above, there's the following piece of JavaScript

$(function() {
  // ...
  var tabPostFix = 'Tab';
  var hash = location.hash;
  if (hash.length > 0) {
    // ...
    var idx = $('.tabPage').index($(".tabPage:"+hash+tabPostFix));
    var thisTab = $('.tab:eq('+idx+')');
    // ...
  }
  // ...
});

where tabPage and tab are classes in HTML file.

Despite I was under the impression that the "dollar syntax" of jQuery used CSS syntax, I eventually found that the syntax $('.tab:eq(some-number)') is indeed valid jQuery syntax, even though it isn't CSS syntax, is it?

On the other hand, I haven't found what $('whatever:#some-hash'). Given the example, I think the .index method is trying to pick the HTML element with class tabPage and id attribute the result of hash+tabPostFix (well, without the leading #), but I don't get the significance of the : right after tabPage.

about 4 years ago · Juan Pablo Isaza
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