Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6009147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:55:46+00:00 2026-05-23T01:55:46+00:00

var currentId = $(‘#nav a’).attr(‘id’); var currentClass = $(‘#circle-inner h1’).attr(‘class’); if(currentClass == currentId) {

  • 0
var currentId = $('#nav a').attr('id');
var currentClass = $('#circle-inner h1').attr('class');
if(currentClass == currentId) {
  $('#nav a').addClass("current");
}

i want to compare the two valuesand if they are the same do something (addClass)

that is what i’m trying to achieve with that piece of code…

i cannot give the value of the class. there are too many.

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:55:46+00:00Added an answer on May 23, 2026 at 1:55 am

    Does #circle-inner h1 only have one class?

    var currentClass = $('#circle-inner h1').attr('class');
    $("#nav a#" + currentClass).addClass("current");
    

    or if the h1 has more than one class, or to reverse the check try:

      $("#nav a").each(function (i) {
      var currentId = $(this).attr('id');
        if ($('#circle-inner h1').hasClass(currentId)) {
          $(this).addClass('current');
         }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my current if/else statement: var current_class = $(this).closest(article).attr(class) if (current_class == 'opened') {
var current = $(this).attr('href'); alert(current); shows the value with '#' eg '#target' instead of
$(body *).live('mouseover', function() { var currentId = $(this).attr('id'); var html = <div id='perfect' style='font-size:10px;'><div
current code I've built function to do something over collection of jQuery elements: var
I find myself using the current pattern quite often in my code nowadays var
I have the following JavaScript function function headerBanner(){ var current = $('.bannerImages img:nth-child('+bannerIndex+')').css('display', 'none');
This code doesn't work: var number = $(this).find('.number').text(); var current = 600; if (current
Environment used: ASP.NET, jQuery I have the following AJAX call: var tempVar = JSON.stringify({plotID:currentId});
I'm trying to extract the current file name in Javascript without any parameters. $(location).attr('href').match(/([a-zA-Z\-\_0-9]+\.\w+)$/);
var current = current + String(c) $('<div id = current > </div>').appendTo('body'); var stt=;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.