Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!