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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:22:45+00:00 2026-05-13T16:22:45+00:00

I have a ul and on hover I want to retrieve the id attribute

  • 0

I have a ul and on hover I want to retrieve the id attribute of the li being hovered over. I have tried selecting the li and on hover I tried to retrieve the ID using the jquery 1.4.1 index function.

$("li").hover(
 function(){
$('#articleimage').append(this.index(this.attr('id')));});

As a simple test, I even tried the following with no results.

$("li").hover(
function(){
  var item = this.attr("id");
  $('#articleimage').append(item);
 }
);

If I am using the Index() function from jquery 1.4.1, I need to specify the ID which I do not know in the first place. This is why I want to harvest the ID on hover of any given li as this ID will be used to associate an image with that li.

Any ideas ?

  • 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-13T16:22:45+00:00Added an answer on May 13, 2026 at 4:22 pm

    Inside any of the event callbacks, this equals the DOM element, not a jQuery wrapper. So first, wrap the element in $() then call index(). There is no need for anything else as index() in jQuery 1.4 defaults to giving you the index from the elements siblings:

    $("li").mousenter(
      function(){
       $('#articleimage').append($(this).index());
      }
    );
    

    Also, I changed hover to mousenter since you were only interested in the first callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a function called when you hover over something (and un-hover).
I have the following jQuery: $(#toolbar).hover(function () { $(.logo).fadeOut(slow, function () { $(this).addClass(logohover) $(this).parent().addClass(logohover).fadeIn(slow,
I have one javascript function. Which i want to call on hover of li
so i have a function for handling elements with a hover, however i want
I have a jquery hover event that fires as you hover over an element.
I have the following code that I want to slim down. $('#1').hover(function() { $('#hiddenMenu1').css('display',
I have a System.Windows.Forms.Button control, and I want to add a hover-text explanation of
I have css hover over images for my tabs and I'm trying to get
I have some hover() JS code: $( '.leftMenuProductWrapper').hover ( function () { }, function
I have an event handler bound to the hover event using the .hover method,

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.