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 9226041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:43:56+00:00 2026-06-18T04:43:56+00:00

This is my first attempt at writing jQuery myself. I’m trying to make it

  • 0

This is my first attempt at writing jQuery myself. I’m trying to make it so when I hover on an instance of a name, the background changes to white as well as all the other instances of that name. Every name has a unique data-id that is common to all it’s instances.

I think my jQuery goes in err at person = this.data("id"); I’m trying to assign the data attribute of the element hovered over and then change the background of all elements with that data attribute. Not sure if I’m even close.

Errors are as follows:

Uncaught TypeError: Object #<HTMLDivElement> has no method 'data' localhost:60
  (anonymous function) localhost:60
  jQuery.event.special.(anonymous function).handle jquery.js:3353
  jQuery.event.dispatch jquery.js:3062
  elemData.handle.eventHandle

timeline

<div id="center">
    <% @instances.each do |instance| %>
        <div class="instance" data-id="<%= instance.person.id %>" style="top:<%=top_helper(instance)%>px; left:<%= left_helper(instance) %>px; width:<%= width_helper(instance) %>px;">
            <span><%= instance.person.first_name %>, <%= instance.rank %></span>
        </div>
    <% end %>
</div>

<script>
    $("div#center").ready(function(){
        var person 
        $("div.instance").hover(function(){
            person = this.data("id");
            $data(person).css("background-color","white");
        });
    });
</script>
  • 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-06-18T04:43:57+00:00Added an answer on June 18, 2026 at 4:43 am

    You’re very close!

    $("div.instance").hover(function(){
        person = $(this).data("id");
        $('div[data-id="' + person + '"]').css("background-color","white");
     });
    

    hover takes two functions as arguments, so your mouseout just does the opposite right after:

    $("div.instance").hover(function(){
        person = $(this).data("id");
        $('div[data-id="' + person + '"]').css("background-color","white");
     },
     function(){
        person = $(this).data("id");
        $('div[data-id="' + person + '"]').css("background-color","gray");
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first attempt at writing a QT app, and I'm just trying
I'm writing an application using DDD techniques. This is my first attempt at a
I'm trying to create a simple threading procedure (granted this is my first attempt
My issue is I am trying my first attempt at writing a very basic
This is my first ever attempt at writing a recursive function in c. The
I am writing this great application. It's my first attempt to write a one
This is my first attempt to build an ASP.NET server control. Writing the control
This is my first-attempt at writing anything even slightly complicated in C++, I'm attempting
This is my first attempt at writing a program that accesses a database from
This is my first attempt at responsive design, so I'm keeping it simple. I

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.