Javascript check what was clicked




















How to get only the element I clicked on? Improve this question. Community Bot 1 1 1 silver badge. The handler function executes in the scope of the element it is added to, here the document.

You will need to get the target property of the event object. Add a comment. Active Oldest Votes. In jQuery, that's Improve this answer. I found that the element that was return was slightly different somehow, so I couldnt do if event. I have been looking for a work around in Safari for 3 days and I finally stumbled upon this post.

You guys rock thanks — Raymond Feliciano. I came here for the right click, so I tried RightClick, but it did not work. For right click - instead of onclick add oncontextmenu — bhv. If a button has a child, you will not get the button, but the clicked child.

If not, only the body tag will return in most cases — bhv. Malek Tubaisaht Malek Tubaisaht 13 13 silver badges 13 13 bronze badges. Should be mentioned in this day and age that on should be recommended over delegate. Good call. We've not upgraded to the most recent jQuery at my day job, so on slips my mind. Safari Mobile 7. See also Safari's docs on making elements clickable and the definition of "clickable element".

Safari Mobile considers the following elements to be typically interactive and thus they aren't affected by this bug :.

Try making rapid, repeated clicks on the button to increase the click count. If you take a break between clicks, the count will reset. Bubbles Yes Cancelable Yes Interface MouseEvent Event handler property onclick If the button is pressed on one element and the pointer is moved outside the element before the button is released, the event is fired on the most specific ancestor element that contained both elements. Chakra UI Vue. Nodejs Show sub menu.

Angular Show sub menu. Angular Material. TypeScript Show sub menu. TypeScript Best Practices. Modern JavaScript. JavaScript Mistakes. JavaScript APIs. Python Show sub menu. Python Answers. Beautiful Soup. Careers Show sub menu. Practice Project Ideas.

Reviews Show sub menu. Useful APIs. Books Show sub menu. Book Reviews. Sign Up for My Mailing List. Developer Tools Show sub menu. Code Formatters Show sub menu. JavaScript Code Beautifier. Crypto Show sub menu. AES Encryptor and Decryptor. MD5 Hash Generator. SHA Hash Generator. SHA Generator. CSV Show sub menu. Content Generators Show sub menu. Canadian Province Array and Select Element. Countries Array and Select Element. Credit Card Number Validator.

Dummy Image Generator. Dummy Text Generator. Fake Address Data Generator. Fake Internet Data Generator. Fake Person Data Generator.

Fake Phone Data Generator.



0コメント

  • 1000 / 1000