{"id":8201,"date":"2010-12-25T08:29:05","date_gmt":"2010-12-25T15:29:05","guid":{"rendered":"http:\/\/css-tricks.com\/"},"modified":"2010-12-25T08:29:05","modified_gmt":"2010-12-25T15:29:05","slug":"check-if-event-was-triggered-or-native","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/jquery\/check-if-event-was-triggered-or-native\/","title":{"rendered":"Check if Event was Triggered or Native"},"content":{"rendered":"
$('button').click(function(event, wasTriggered) {\r\n    if (wasTriggered) {\r\n        alert('triggered in code');\r\n    } else {\r\n        alert('triggered by mouse');\r\n    }\r\n});\r\n\r\n$('button').trigger('click', true);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

$(‘button’).click(function(event, wasTriggered) { if (wasTriggered) { alert(‘triggered in code’); } else { alert(‘triggered by mouse’); } }); $(‘button’).trigger(‘click’, true);<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3245,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":151204,"url":"https:\/\/css-tricks.com\/lodge\/learn-jquery\/14-custom-events\/","url_meta":{"origin":8201,"position":0},"title":"#14: Custom Events","date":"September 27, 2013","format":false,"excerpt":"Since we just talked about events, now is a good time to mention custom events. All the events that we've talked about so far are \"real\" events so to speak. Events that originate in the DOM based on real things that happen, like a click or key press. These events\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":21048,"url":"https:\/\/css-tricks.com\/video-screencasts\/123-if-it-moves-when-you-click-make-something-stick\/","url_meta":{"origin":8201,"position":1},"title":"#123: If it Moves When You Click, Make Something Stick","date":"April 9, 2013","format":false,"excerpt":"The buttons on CSS-Tricks, at the time of this video, have a faux 3D effect. They look like a blue brick you are looking at from above at an angle. When you press down on them, their :active state is triggered (like all links\/buttons\/inputs) and the CSS moves them down\u2026","rel":"","context":"With 14 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345532,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/b\/backdrop\/","url_meta":{"origin":8201,"position":2},"title":"::backdrop","date":"August 3, 2021","format":false,"excerpt":"The ::backdrop CSS pseudo-element creates a backdrop that covers the entire viewport and is rendered immediately below a

or any element that enters fullscreen mode using the Fullscreen API. dialog::backdrop { background-color: darkorange; } The backdrop is selectable as a pseudo-element when an element is opened in the browser\u2019s\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/backdrop-diagram.png?fit=975%2C527&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":14267,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/r\/required\/","url_meta":{"origin":8201,"position":3},"title":":required","date":"September 6, 2011","format":false,"excerpt":"The :required pseudo class selector in CSS allows authors to select and style any matched element with the required attribute. Forms can easily indicate which fields must have valid data before the form can be submitted, but allows the user to avoid the wait incurred by having the server be\u2026","rel":"","context":"With 12 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":373609,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/a\/autofill\/","url_meta":{"origin":8201,"position":4},"title":":autofill","date":"September 27, 2022","format":false,"excerpt":"The :auto-fill pseudo-class in CSS allows us to style elements that contain content auto-filled by the browser. Take a new user registration form as an example. Have you ever clicked or tapped into a field and seen a dropdown of suggestions for what to enter? Notice how the autocompleted\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/12\/css-tricks-logo-gradient-outline.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":248134,"url":"https:\/\/css-tricks.com\/video-screencasts\/150-hey-designers-know-one-thing-javascript-recommend\/","url_meta":{"origin":8201,"position":5},"title":"#150: Hey designers, if you only know one thing about JavaScript, this is what I would recommend","date":"November 23, 2016","format":false,"excerpt":"Sometimes, to start a journey into learning something huge and complex, you need to learn something small and simple. JavaScript is huge and complex, but you can baby step into it by learning small and simple things. If you're a web designer, I think there is one thing in particular\u2026","rel":"","context":"With 14 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/8201"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=8201"}],"version-history":[{"count":1,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/8201\/revisions"}],"predecessor-version":[{"id":8202,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/8201\/revisions\/8202"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3245"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=8201"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=8201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}