control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/dblclick.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
3.5 KiB
JSON

{"name":"dblclick","type":"method","title":".dblclick()","deprecated":null,"removed":null,"desc":"Bind an event handler to the \"dblclick\" JavaScript event, or trigger that event on an element.","categories":["events/mouse-events","version/1.0","version/1.4.3"],"entries":[{"return":"jQuery","signatures":[{"added":"1.0","argument":{"desc":"A function to execute each time the event is triggered.","name":"handler(eventObject)","type":"Function"}},{"added":"1.4.3","argument":[{"desc":"An object containing data that will be passed to the event handler.","name":"eventData","type":"Object","optional":"true"},{"desc":"A function to execute each time the event is triggered.","name":"handler(eventObject)","type":"Function"}]},{"added":"1.0"}],"examples":[{"desc":"To bind a \"Hello World!\" alert box the dblclick event on every paragraph on the page:","code":"\n$( \"p\" ).dblclick(function() {\n alert( \"Hello World!\" );\n});\n"},{"desc":"Double click to toggle background color.","code":"\nvar divdbl = $( \"div:first\" );\ndivdbl.dblclick(function() {\n divdbl.toggleClass( \"dbl\" );\n});\n","css":"\n div {\n background: blue;\n color: white;\n height: 100px;\n width: 150px;\n }\n div.dbl {\n background: yellow;\n color: black;\n }\n","html":"\n<div></div>\n<span>Double click the block</span>\n"}],"longdesc":"\n <p>This method is a shortcut for <code>.on( \"dblclick\", handler)</code> in the first two variations, and <code>.trigger( \"dblclick\" )</code> in the third.\n The <code>dblclick</code> event is sent to an element when the element is double-clicked. Any HTML element can receive this event.\n For example, consider the HTML:</p>\n <pre><code>\n&lt;div id=\"target\"&gt;\n Double-click here\n&lt;/div&gt;\n&lt;div id=\"other\"&gt;\n Trigger the handler\n&lt;/div&gt;\n </code></pre>\n <p class=\"image\">\n <img src=\"/resources/0042_05_04.png\" alt=\"\"/>\n </p>\n <p>The event handler can be bound to any <code>&lt;div&gt;</code>:</p>\n <pre><code>\n$( \"#target\" ).dblclick(function() {\n alert( \"Handler for .dblclick() called.\" );\n});\n </code></pre>\n <p>Now double-clicking on this element displays the alert:</p>\n <p>\n <samp>Handler for .dblclick() called.</samp>\n </p>\n <p>To trigger the event manually, apply <code>.dblclick()</code> without an argument:</p>\n <pre><code>\n$( \"#other\" ).click(function() {\n $( \"#target\" ).dblclick();\n});\n </code></pre>\n <p>After this code executes, (single) clicks on <samp>Trigger the handler</samp> will also alert the message.</p>\n <p>The <code>dblclick</code> event is only triggered after this exact series of events:</p>\n <ul>\n <li>The mouse button is depressed while the pointer is inside the element.</li>\n <li>The mouse button is released while the pointer is inside the element.</li>\n <li>The mouse button is depressed again while the pointer is inside the element, within a time window that is system-dependent.</li>\n <li>The mouse button is released while the pointer is inside the element.</li>\n </ul>\n <p>It is inadvisable to bind handlers to both the <code>click</code> and <code>dblclick</code> events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two <code>click</code> events before the <code>dblclick</code> and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.\n </p>\n "}]}