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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:22:40+00:00 2026-06-14T07:22:40+00:00

Im trying to build a mini inspector tool that simply reports the element being

  • 0

Im trying to build a mini inspector tool that simply reports the element being hovered over, its ID and any classes it has.

I built a demo page which has 4 nested elements:

html > body > outerContainer > innerContainer

I have managed to get it working to a fashion, it reports the information correctly when going from the outer elements to the inner elements, but when going in reverse, the reported element is the previous one.

To see it in action – http://jsfiddle.net/sygad/kmJ5s/

<head>

    <meta charset="utf-8">

    <title>Element Hover</title>

    <style>

        html                {margin:0; padding:40px 20px 0; background:#333; font:0.9em/1.1em "Arial", sans-serif}
        body                {margin:0; padding:0 0 10px; background:#555}

        #outerContainer     {margin:20px; padding:0; background:#777; width:240px; height:260px;}
        #innerContainer     {margin:20px; padding:0; background:#999; width:200px; height:200px;}

        p#info              {position:absolute; top:0; left:0}
        p                   {margin:0; padding:0; color:white}

    </style>

</head>

<body>

    <p id="info">Current element: <span></span></p>

    <p>Body</p>

    <div id="outerContainer">
        <p>Outer</p>

        <div id="innerContainer">
            <p>Inner</p>
        </div>

    </div>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>

    <script>

        //Initialise
        var nodeName = '';
        var ids = '';
        var classes = '';

        $('*').hover(function(e)
        {
            //Clear
            nodeName = '';
            ids = '';
            classes = '';

            nodeName = $(this).context.nodeName.toLowerCase();

            if ($(this).attr('id') != undefined)
            {
                ids = ' #' + $(this).attr('id');
            }

            if ($(this).attr('class') != undefined)
            {
                classes = ' .' + $(this).attr('class');
            }

            $('p#info span').text(nodeName+ids+classes)
        })
    </script>

</body>

  • 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-14T07:22:41+00:00Added an answer on June 14, 2026 at 7:22 am

    You need to take care of below items,

    1. You should really implement this onmousemove because when you move inside child elements from a parent and leave a child element, it won’t update for parent as you never enter/leave the parent element.
    2. You should use e.target instead of this
    3. Clear off global vars as it might carry over to next element.

    DEMO: http://jsfiddle.net/kmJ5s/8/

    var nodeName = '';
    var ids = '';
    var classes = '';
    
    $('*').mousemove(function(e) {
        nodeName = '';
        ids = '';
        classes = '';
        var _this = e.target;
        nodeName = _this.nodeName.toLowerCase();
    
        if (_this.id) {
            ids = ' #' + _this.id;
        }
    
        if (_this.className) {
            classes = ' .' + _this.className;
        }
    
        $('p#info span').text(nodeName + ids + classes)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying build a regex that will replace any characters not of the format:
I'm trying to build a calendar system that would show 3 mini-calendar months. Last
I'm trying to build zimbra from source on a mac mini running on mac
i'm trying to build a mini reply system, based on the user's posts on
I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
Trying to build a plugin effect that will some what look better than this
I'm trying to build a mini cms, whereby all urls go to the index
Im trying to build a script that attaches and positions an instance of a
Trying to build a user interface using PyQt4. Got a dialog window that pops
Im trying to build a somewhat advanced "Flot" jQuery pluging graph. For that, 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.