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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:07:08+00:00 2026-06-06T13:07:08+00:00

So, the code i will give you is terrible…i tried to figure it out,

  • 0

So, the code i will give you is terrible…i tried to figure it out, but javascript seems to be unlearnable to me.

I have a dynamically generated unordered list. When the user hovers over each list item, I would like to display more information in a separate div.

heres what I have html/php wise:

<div id="inv">
<ul>
<?php 
$i = 1;
foreach ($inv as $item) {
    echo "<li class='inventory' id='$i'>";
    echo $item['name'] . "<input type=button value='destroy'></input> ";
    echo "</li>";
    $i ++;
}
?>
</ul>
</div>
<?php 
$i = 1;
foreach ($inv as $item) {
echo "<div class='inventory_display' id='$i'>".$item['name']."</div>";
$i ++;
}

CSS:

#inventory ul {
    list-style: none;
}
#inventory li {
    background-color: #B3B4BD;
    color: white;
}

#inventory li:hover {
    background-color: #9bc2d0;
    color: black;
    cursor: pointer;
}

#inventory {
    float:left;
    width: 500px;
}

#inventory_display {
    display: none;
    margin-left: 420px;
    position: absolute;
    width: 300px;
    height: 300px;
    background-color: #97cae6;
}

I assume I need javascript, but really have no idea where to start. Pasting what I have would probably only cause more confusion.

I’d be happy with a simple hover display to appear, but will probably seek to make hover display it, and a click make it static.

Thanks. please let me know if any more information is required! If its too much trouble for a full answer, any place to start, like links, etc would be helpful too.

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-06-06T13:07:10+00:00Added an answer on June 6, 2026 at 1:07 pm

    move $item['name'] into the rel attribute of the li.

    echo "<li class='inventory' id='$i' rel="$item['name']">";
    

    Now, we can use jQuery to append an element to it, and display the rel inside of that div.

    CSS needs to change, as well

    #inventory li{
      background-color: #B3B4BD;
      color: white;
      /* Add this */
      position:relative;
    }
    

    new Class.

    .li-tooltip{
      position:absolute;
      top:0;
      /* other css stuff, we'll do the width and height later. */
    }
    

    Let’s use jQuery now to do some beautiful stuff.

    $('#inventory li').hover(function(){
      //this is the "mouse in"
      // find the width of the LI, so we can use that to decide positioning.
       var liW = $(this).width();
      $('<div class="li-tooltip">'+$(this).attr('rel')+'</div>').css('left', liW).appendTo($(this));
    }, function(){
      //this is the "mouseout"
      $('.li-tooltip').remove();
    });
    

    Here is the working jsFiddle

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

Sidebar

Related Questions

I know the code is missing (Someone will give negative numbers). But I only
The code bellow will give compile error on line enum en = A::en; but
I have the following piece of code that will give me the date 1
I am looking for javascript code which will give me 1st date of the
Which code snippet will give better performance? The below code segments were written in
I am trying to achieve a pattern matching in perl code. I will give
The following code will search for the user within the domain controller, but I
The following code will give a hard fail when run under Windows 7 32bit:
I have the following situation below. This code will throw a compiler error for
I'm trying to create three separate graphs, this code will give you the idea:

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.