If you put a .click() on a div element and you got an input element in the div.. how can you then omit the .click() if the user clicks on the input?
The div.click() only has to trigger when the user click inside the div, but outside the input element
<div style="width:400px; height:200px">
<input type="text" style="width:50px" />
</div>
You have two choices:
Attach a
clickevent handler to the input element and prevent the event from bubbling up by callingevent.stopPropagation()[docs]:OR
Inspect the
event.target[docs] in theclickevent handler attached to thedivwhether the target is theinputelement or not. Something like: