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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:49:12+00:00 2026-05-14T08:49:12+00:00

When using : document.onmouseover = function(e) {} Is there a property which gives me

  • 0

When using :

document.onmouseover = function(e) {}

Is there a property which gives me the element in the dom tree ?

For example, I can set a style to e.srcElement
But, how can I later access this element to (for example) reset its style ?
And how can I know at which place in the dom tree it is ?
I want to be able to situate it in the whole page dump.

Many thanks.

To solve the problem about reaccessing the element later, I tried this but it doesn’t work :

var lastelem;

document.onmouseover = function(e) {

  if (lastelem != null){
    lastelem.style.border = "0px";
  }

  if (e===undefined) e= window.event;
  var target= 'target' in event? event.target : event.srcElement;
  document.getElementById('display').value = target.tagName;
  target.style.border = "1px";
  lastelem = target;
};

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-05-14T08:49:12+00:00Added an answer on May 14, 2026 at 8:49 am

    Which HTML element is the target of the event? (on Quirksmode.org, by Peter-Paul Koch). Also have a look at the target attribute of the Event object in W3C DOM Level 2 Event Model.

    <!DOCTYPE html>
    <html>
      <head>
        <title>target test</title>
        <style>
          *        { border: 1px solid #fff }
          .trigger { background: lightgreen }
        </style>
      </head>
      <body>
        <p class="trigger">Trigger testCase().</p>
        <p class="trigger">Trigger testCase().</p>
        <p class="trigger">Trigger testCase().</p>
        <p id="display"></p>
        <script>
    var lastelem;
    
    document.onmouseover = function (e) {
            var event = e || window.event;
    
            if (lastelem) {
                    lastelem.style.border = "1px solid #fff";
            }
    
            var target = event.target || event.srcElement;
            document.getElementById('display').innerHTML = target.previousSibling.tagName +
                " | " + target.tagName + " | " + (target.nextSibling ? target.nextSibling.tagName : "X");
            target.style.border = "1px solid";
            lastelem = target;
    };
        </script>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the focus on a text input element using document.getElementById( 'id'
I know I can grab the entire referring url by using: document.referrer But how
<Select> <option value=1>One</option> <option value=2>Two</option> <option value=3>Three</option> </Select> I am using document.getElementById(Example).value; to get
I'm using the following code to hide a division on the page load: $(document).ready(function()
The function isn't working when i'm using $(document).ready(function () { ..... }); but it
I'm performing a very simple onmouseover fadeTo like this: $(document).ready(function() { $('img#logo-link, a.advert').hover(function() {
By using document.referrer we will get all the reference of URL in JavaScript, such
when using document's id as the only criteria in my query what's the difference
I am using document.getItemValueString(INetSendTo) to get the mail address of recipient exact mail address.
I have a variable when i write its value using document.write() i don't get

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.