Home  >  Article  >  Web Front-end  >  Detailed explanation of mouseup event attribute loss in jquery

Detailed explanation of mouseup event attribute loss in jquery

黄舟
黄舟Original
2017-06-28 14:27:282103browse

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);  
});

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);  
});

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

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!

Statement:
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