How to use javascript to get the object where the mouse is located _ javascript skills

Source: Internet
Author: User
Use js to get the object where the mouse is located

<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN"> <HTML> <HEAD> <TITLE> get the object where the mouse is located </TITLE> <META NAME = "Author" CONTENT = "Baoyu [url] http://www.nwpubbs.net [/Url] "> </HEAD> <script language =" javascript "> <! -- Function fnGetTable (oEl) {try {while (null! = OEl & oEl. tagName! = "TABLE") {oEl = oEl. parentElement;} return oEl;} catch (e) {return null ;}} function pos () {try {oElement = document. elementFromPoint (event. x, event. y); oElement = fnGetTable (oElement); if (oElement. tagName = "TABLE") show. innerText = oElement. id;} catch (e) {}}// --> script <BODY onmousemove = "pos () "> <table border =" 1 "cellpadding =" "cellspacing =" "width =" "id =" table1 "> <tr> <td> table1 </td> </ tr> </table> <table border = "1" cellpadding = "" cellspacing = "" width = "" id = "table2"> <tr> <td> table2 </ td> </tr> </table> <table border = "1" cellpadding = "" cellspacing = "" width = "" id = "table3"> <tr> <td> table3 </td> </tr> </table> <table border = "1" cellpadding = "" cellspacing = "" width = "" id = "table4"> <tr> <td> table4 </td> </tr> </table> <table border = "1" cellpadding = "" cellspacing = "" width = "" id =" table5 "> <tr> <td> table5 </td> </tr> </table> <table border =" 1 "cellpadding =" "cellspacing =" "width =" "id =" table6 "> <tr> <td> table6 </td> </tr> </table>: </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.