{"id":321355,"date":"2021-02-05T14:15:15","date_gmt":"2021-02-05T06:15:15","guid":{"rendered":"http:\/\/4563.org\/?p=321355"},"modified":"2021-02-05T14:15:15","modified_gmt":"2021-02-05T06:15:15","slug":"onmouseover-function-%e8%bf%99%e7%a7%8d%e5%86%99%e6%b3%95%ef%bc%8c%e5%a6%82%e4%bd%95%e4%bc%a0%e5%85%a5%e5%85%83%e7%b4%a0%e5%af%b9%e8%b1%a1%e6%9c%ac%e8%ba%ab%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=321355","title":{"rendered":"onmouseover = function ()\u8fd9\u79cd\u5199\u6cd5\uff0c\u5982\u4f55\u4f20\u5165\u5143\u7d20\u5bf9\u8c61\u672c\u8eab\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  onmouseover = function ()\u8fd9\u79cd\u5199\u6cd5\uff0c\u5982\u4f55\u4f20\u5165\u5143\u7d20\u5bf9\u8c61\u672c\u8eab\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qazwsxkevin <\/span>  <span><i><\/i> 10<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e3a\u4e86\u5bb9\u6613\u7ef4\u62a4\uff0c\u65b9\u4fbf\u533a\u5206\u8868\u683c\uff0c\u548c\u6d4b\u8bd5\u7b49\u4e8b\u60c5<br \/> \u6211\u6ca1\u6709\u5728 testtbl \u7684 table \u6807\u7b7e\u4e0a\u4f7f\u7528 onmouseover=someFunction(event,this)\u7684\u65b9\u5f0f\u53bb\u8c03\u7528\u51fd\u6570&#8230;<br \/> \u76ee\u524d\u53ea\u7528.onmouseover = function ()\u7684<\/p>\n<pre><code>    tartable = document.getElementById('testtbl');     tartable.onmouseover = function (event,obj) { \/\/ &lt;--obj \u6539 this \u662f\u4e0d\u884c\u7684         t_clientX = event.clientX - obj.offsetLeft;         y_clientY = event.clientY - obj.offsetTop;         document.all('tester').innerHTML = t_clientX     } <\/code><\/pre>\n<p>\u60f3\u83b7\u5f97\u9f20\u6807\u5728 testtbl \u8fd9\u4e2a\u8868\u683c\u5143\u7d20\u5185\u7684 tx,ty \u5750\u6807\uff0c<br \/> \u7136\u540e\u53ea\u5728\u8868\u683c\u8303\u56f4\u5185\u753b\u4e00\u4e2a\u8ddf\u968f\u9f20\u6807\u6e38\u52a8\u7684\u5341\u5b57\u51c6\u661f\u5149\u6807<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5057323\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ashong <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             =function(e){<br \/>e.target<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057324\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u662f\u60f3\u83b7\u53d6 tartable \u672c\u8eab\uff1f<br \/>document.getElementById(&#8216;testtbl&#8217;).onclick = function(e){ console.log(e.target) }<br \/>\u6216\u8005<br \/>document.getElementById(&#8216;testtbl&#8217;).onclick = function(){ console.log(this) }<br \/>\u90fd\u884c\uff0c\u5efa\u8bae\u7b2c\u4e8c\u79cd                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057325\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dd112389 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u61c2\u4e3b\u7684\u63cf\u8ff0.<br \/>\u8fd8\u6709 document.all \u4e0d\u662f\u4e2a\u65b9\u6cd5\u662f\u4e2a\u5bf9\u8c61\u5427. \u53c2\u8003: https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/API\/Document\/all<br \/>\u5982\u679c\u662f\u60f3\u5728\u4e00\u4e2a\u5bb9\u5668\u5185\u83b7\u53d6\u5750\u6807\u76f4\u63a5\u7ed1\u5b9a mousemove \u4e8b\u4ef6\u7136\u540e\u62ff event \u83b7\u53d6\u4e0d\u5c31\u597d\u4e86\uff1f<br \/>\u5982\u679c\u4f60\u662f\u60f3\u5728\u4e8b\u4ef6\u4e2d\u62ff\u5230\u81ea\u8eab\u5143\u7d20\u7684\u8bdd\u53ef\u4ee5\u8fd9\u6837\u5199:<br \/>let table = document.querySelector(&#8216;#testtbl&#8217;);<br \/>table.onmousemove = function () {<br \/> console.log(this === table) \/\/ true<br \/>}<br \/>\u6216\u8005<br \/>table.onmousemove = () =&gt; {<br \/> console.log(table) \/\/ Element<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057326\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Elethom <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u73b0\u5728\u4e0d\u4f1a\u8bfb\u6587\u6863\u4e5f\u80fd\u5f53\u7a0b\u5e8f\u5458\u4e86\u5417\u3002<br \/>https:\/\/www.google.com\/search?q=onmouseover+mozilla                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057327\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : qazwsxkevin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Elethom \u62b1\u6b49\uff0c\u6b63\u804c\u8fd8\u771f\u7684\u4e0d\u662f\u7a0b\u5e8f\u5458\uff0c\u4e34\u65f6\u4e34\u6025\u8981\u4e0a\u4e00\u4e9b\u529f\u80fd\uff0c\u5982\u679c\u6253\u6270\u60a8\u4e86\uff0c\u4e07\u5206\u62b1\u6b49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057328\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : krixaar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u95ee\u9898\u8fd8\u6ca1\u89e3\u51b3\u5462\uff0c\u4e0d\u90a3\u4e48\u5b8c\u7f8e\u4e3b\u4e49\u7684\u8bdd\uff0c\u6362\u6211\u65e9\u5c31\u4e00\u4e2a\u5341\u5b57\u7ebf.svg \u52a0\u51e0\u884c css \u641e\u5b9a\u4e86\uff0c\u81f3\u4e8e\u5341\u5b57\u7ebf\u8d85\u51fa\u8868\u683c\u8303\u56f4\u4e86\uff0c\u53c8\u4e0d\u662f\u5f3a\u8feb\u75c7\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057329\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rodrick <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             mouseover \u662f\u79fb\u5165\u4e8b\u4ef6\uff0ce.target \u662f\u79fb\u5165\u76ee\u6807\u5143\u7d20\uff0ce.relatedTarget \u662f\u79fb\u51fa\u5bf9\u8c61\u3002\u5b50\u5143\u7d20\u7684 mouseover \u662f\u4f1a\u5192\u6ce1\u7684\uff0c\u5192\u6ce1\u4e2d e.target \u662f\u5f53\u524d\u5192\u6ce1\u5230\u7684\u5143\u7d20\uff0c\u800c this \u662f event \u53d1\u751f\u7684\u5143\u7d20\u3002\u6ce8\u610f\u4e00\u4e0b\u8fd9\u51e0\u70b9\u5c31\u5dee\u4e0d\u591a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5057330\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SoloCompany <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u88ab document.all \u7b11\u5230                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>onmouseover = fun&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/321355"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321355"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/321355\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321355"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}