Home > Web Front-end > JS Tutorial > body text

Detailed explanation of mouseup event attribute loss in jquery

黄舟
Release: 2017-06-28 14:27:28
Original
2046 people have browsed it

I am writing js recently, ah, js cross-browser Events are lost too much, and jquery is the same. .

The author recently wrote a demo... This problem has troubled me for a week. . .

The code explains the reason:

$("#div1").mouseup(function(e) {  
    alert(e.target.id);  
});
Copy after login

I really hope to get the ie of the dom object triggered by the object after the mouse is released. ..All elements on the page have ids. . .

Finally solved

$("#div1").mouseup(function(e) {  
    var oEvent=e||event;  
    alert(oEvent.target.id);  
});
Copy after login

Ah, annoying js

Insert a small knowledge point here:

The coordinates of mouse movement in mousemove Determine the current moving node type. id

document.elementFromPoint(oEvent.pageX,oEvent.pageY).id;//获取di  
  
document.elementFromPoint(oEvent.pageX,oEvent.pageY).tagName;//获取节点tag name
Copy after login

The above is the detailed content of Detailed explanation of mouseup event attribute loss in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!