I'm trying to set conditions on a jQuery event. I have an input element and a div. I want to detect a click anywhere on the page and to execute that method but only if the click is not on the input or div.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Basically assign a click handler to the body of the page, then test the target Element of the event to see if the id of that target element matches your div or your input.
Example to exclude specific elements using a wildcard:
Something like this should work.
Use the jQuery click() or live() functions and then check the target of the click event using the jQuery is() function.
.
Example webpage => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-document-click-exclusion.html
Example firebug output after clicking around on example page