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

  • Home
  • SEARCH
  • 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 7497771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:13:24+00:00 2026-05-29T19:13:24+00:00

I am using jQuery 1.7.1. I am trying to hightlight a column of divs

  • 0

I am using jQuery 1.7.1.

I am trying to hightlight a column of divs if the column head div is hovered over.

If a div with the class of PC_ColumnHeadDiv has a data-col=”3″ attribute, I want to add a class to all of the divs with the PC_CellSpecValuesDiv class that have a data-col=”3″ attribute.

var PC_ColumnHeadDiv = $(".PC_ColumnHeadDiv"); 
var PC_CellSpecValuesDiv = $(".PC_CellSpecValuesDiv"); 

$(PC_ColumnHeadDiv).hover(
    function() {
        var C = $(this).data("col");
        $(PC_CellSpecValuesDiv).data("col:"+C).addClass("PC_Over");
    }, 
    function(){
        $(PC_CellSpecValuesDiv).removeClass("PC_Over");
    }   
);

The problem piece of code is this:

$(PC_CellSpecValuesDiv).data("col:"+C).addClass("PC_Over");

What I am trying to do here is find all of the divs CellSpecDivs where the data-col attribute is set to 3.

$(PC_CellSpecValuesDiv).data("col", 3).addClass("PC_Over");
$(PC_CellSpecValuesDiv).data("col").is(3).addClass("PC_Over");
$(PC_CellSpecValuesDiv).data("col").eq(3).addClass("PC_Over");

What’s the right way to get this line to work?

EDIT

This line works. Is this the best way to code this, assuming the rest will stay the same?

$(PC_CellSpecValuesDiv).filter("[data-col='"+C+"']").addClass("PC_Over");
  • 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-29T19:13:24+00:00Added an answer on May 29, 2026 at 7:13 pm

    You can use the .filter() method.

    PC_CellSpecValuesDiv.filter('[data-col=' + C + ']').addClass('PC_over');
    

    It will check the current set of matched element for the attribute “data-col”. In case the element does not have that attribute, addClass() will have no effect, otherwise, the class name will be added.

    DEMO


    Some notes on your code:

    • this double work to do:

      var PC_ColumnHeadDiv = $(".PC_ColumnHeadDiv");
      $(PC_ColumnHeadDiv) // "PC_ColumnHeadDiv" is a already jquery object
      PC_ColumnHeadDiv.hover(...) // just use "PC_ColumnHeadDiv"
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make simple script using jquery $post function to pass data to
I have 2 dropdown lists on my webform and using jquery trying to filter/reset
Using jQuery I am trying to set focus for (CSS purposes) to a particular
using jquery ui 1.8 trying autocomplete Everything works apart from that the ui-menu isn't
I am trying to display a button using jQuery template. The code is as
I am trying to invoke webservice using jquery ajax call. I am using jasonp
I'm trying to implement authentication using jquery to make an ajax request to a
I´m trying to open a tab using jquery, here is my code: $(#ecContenedorFolders).tabs({ tabTemplate:
I am using jquery ui (datapicker) and trying simpledialog2 http://dev.jtsage.com/jQM-SimpleDialog/demos2/index.html If I include reference
I'm trying to do an AJAX request using Jquery. The JS file is located

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.