Home  >  Article  >  Web Front-end  >  html event attribute onmousedown triggered when the mouse button is pressed on the element

html event attribute onmousedown triggered when the mouse button is pressed on the element

黄舟
黄舟Original
2017-11-06 11:00:054814browse

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

onmousedown onmouseup onclick

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(&#39;click&#39;).on(&#39;click&#39;, function(e) {
            if($(e.target).closest(&#39;.clickHeadTo&#39;).length || $(e.target).closest(&#39;.content-right-empty&#39;).length){
                return;
            }
            if(!$(e.target).closest(&#39;.not-hide-floater&#39;).length){
                $(&#39;.em-floater&#39;).hide();
            }
            $scope.isShowGroupMember = false;
            $scope.isShowMember = true;
            $scope.isHideMember = false;
            if($scope.deptCount > 1){
                $scope.countVisible = true;
            }
            $scope.visible = false;
            $scope.$apply();
            $(&#39;[recentUserId=&#39; + localStorage.getItem(&#39;recentUserId&#39;) + &#39;]&#39;).addClass(&#39;on&#39;);
        });
//点击任意出关闭右键弹窗
        $(document).off(&#39;click&#39;).on(&#39;click&#39;, 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!

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