Home > Article > Web Front-end > html event attribute onmousedown triggered when the mouse button is pressed on the element
Example
Execute a paragraph when the mouse button is pressed on the paragraphJavaScript:
<p onmousedown="mouseDown()">请点击此文本!</p>
Browser support
IE
Firefox
Chrome
Safari
Opera
All major browsers support the onmousedown attribute.
Definition and Usage
The onmousedown attribute is triggered when the mouse button is pressed on the element.
Tips: Event order relative to onmousedown event (limited to left/middle mouse button):
Event order relative to the onmousedown event (limited to the right mouse button):
onmousedown onmouseup oncontextmenu
Note: The onmousedown attribute does not apply to the following elements: dde6fb694e6711ae5e6f381704c04ae4, < ;bdo>, 0c6dc11e160d3b678d68754cc175188a, 93f0f5c25f18dab9d176bd4f6de5d30e, 100db36a723c770d327fc0aef2ce13b1, d5ba1642137c3f32f4f4493ae923989c, e8e496c15ba93d81f6ea4fe5f55a2244, 0c68fef83818661b6da588c77ca3985e, 3f1c4e4b6b16bbbd69b2ee476dc4f83a, c9ccee2e6ea535a969eb3f532ad9fe89 or b2386ffb911b14667cb8f0f91ea547a7.
Differences between HTML 4.01 and HTML5
None.
Syntax
<element onmousedown="script">
Attribute value
script The script to run when onmousedown occurs.
document.onmousedown = function() { $scope.isShowDisQuit = false; $scope.isShowJoinGroup = false; };
//点击任意出关闭表情框 $(document).off('click').on('click', function(e) { if($(e.target).closest('.clickHeadTo').length || $(e.target).closest('.content-right-empty').length){ return; } if(!$(e.target).closest('.not-hide-floater').length){ $('.em-floater').hide(); } $scope.isShowGroupMember = false; $scope.isShowMember = true; $scope.isHideMember = false; if($scope.deptCount > 1){ $scope.countVisible = true; } $scope.visible = false; $scope.$apply(); $('[recentUserId=' + localStorage.getItem('recentUserId') + ']').addClass('on'); });
//点击任意出关闭右键弹窗 $(document).off('click').on('click', function(e) { $scope.iscontextMenus = false; if (!$scope.$$phase) { $scope.$apply(); } })
//群会话消息滚动事件触发关闭右键弹层 groupTarget.onscroll = function (){ isContextMenusHide(); } //鼠标抬起时关闭右键弹层 document.onmouseup = function() { isContextMenusHide(); }; function isContextMenusHide (){ $scope.iscontextMenus = false; if (!$scope.$$phase) { $scope.$apply(); } }
The above is the detailed content of html event attribute onmousedown triggered when the mouse button is pressed on the element. For more information, please follow other related articles on the PHP Chinese website!